| <html> |
| <script> |
| function test() { |
| var tf = document.getElementById('tf'); |
| tf.focus(); |
| if (window.testRunner) { |
| testRunner.dumpAsText(); |
| eventSender.keyDown('F'); |
| eventSender.keyDown('A'); |
| eventSender.keyDown('I'); |
| eventSender.keyDown('L'); |
| log(tf.value); |
| } |
| } |
| |
| function log(msg) { |
| var res = document.getElementById('res'); |
| res.innerHTML = res.innerHTML + msg + "<br>"; |
| } |
| </script> |
| <body onload="test()"> |
| This tests that preventing the default behavior for a keydown event will prevent the keypress event from firing, and will prevent text from being inserted.<br> |
| This matches IE7, but not Firefox, which still dispatches a keypress.<br> |
| <input id="tf" onkeydown="log('key down'); return false" onkeypress="log('key press')"> |
| <br> |
| <div id="res"></div> |
| </body> |
| </html> |