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