blob: aa474e937eb1de7efb27a419a72a98f601c275da (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<html>
<body>
<p>Typing in the input fields below should not generate text, even with an IME enabled.</p>
Type into the input:
<input type=text id='input'></input><br>
<div id='out' style="float: right"></div>
Or the text area:
<textarea id='area'></textarea><br>
Or the contentEditable area:
<div contentEditable id='ce' style="border:1px solid red; height:300px; width:300px;"></div>
<script>
var input = document.getElementById('input');
var area = document.getElementById('area');
var ce = document.getElementById('ce');
var handleKeyDown = function(e) {
document.getElementById('out').innerHTML += "<br>Got a key event -- cancelling";
e.preventDefault();
}
input.addEventListener('keydown', handleKeyDown, false);
area.addEventListener('keydown', handleKeyDown, false);
ce.addEventListener('keydown', handleKeyDown, false);
</script>
</body>
</html>
|