mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
48 lines
1.2 KiB
HTML
48 lines
1.2 KiB
HTML
<!DOCTYPE html>
|
|
<input id="input" />
|
|
<script src="../include.js"></script>
|
|
<script>
|
|
test(() => {
|
|
let input = document.getElementById("input");
|
|
input.value = "You can't change me!";
|
|
|
|
input.focus();
|
|
input.select();
|
|
|
|
let shouldCancelKeyDown = false;
|
|
let shouldCancelKeyPress = false;
|
|
|
|
input.addEventListener("keydown", e => {
|
|
println(`keydown ${e.key}`);
|
|
|
|
if (shouldCancelKeyDown) {
|
|
println("cancel keydown");
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
input.addEventListener("keypress", e => {
|
|
println(`keypress ${e.key}`);
|
|
|
|
if (shouldCancelKeyPress) {
|
|
println("cancel keypress");
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
shouldCancelKeyDown = true;
|
|
shouldCancelKeyPress = false;
|
|
internals.sendText(input, "A");
|
|
println(input.value);
|
|
|
|
shouldCancelKeyDown = false;
|
|
shouldCancelKeyPress = true;
|
|
internals.sendText(input, "B");
|
|
println(input.value);
|
|
|
|
shouldCancelKeyDown = false;
|
|
shouldCancelKeyPress = false;
|
|
internals.sendText(input, "C");
|
|
println(input.value);
|
|
});
|
|
</script>
|