| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script> | 3 <script> |
| 4 | 4 |
| 5 function keyLocationToText(location) | 5 function keyLocationToText(location) |
| 6 { | 6 { |
| 7 switch (location) { | 7 switch (location) { |
| 8 case KeyboardEvent.DOM_KEY_LOCATION_STANDARD: | 8 case KeyboardEvent.DOM_KEY_LOCATION_STANDARD: |
| 9 return "DOM_KEY_LOCATION_STANDARD"; | 9 return "DOM_KEY_LOCATION_STANDARD"; |
| 10 case KeyboardEvent.DOM_KEY_LOCATION_LEFT: | 10 case KeyboardEvent.DOM_KEY_LOCATION_LEFT: |
| 11 return "DOM_KEY_LOCATION_LEFT"; | 11 return "DOM_KEY_LOCATION_LEFT"; |
| 12 case KeyboardEvent.DOM_KEY_LOCATION_RIGHT: | 12 case KeyboardEvent.DOM_KEY_LOCATION_RIGHT: |
| 13 return "DOM_KEY_LOCATION_RIGHT"; | 13 return "DOM_KEY_LOCATION_RIGHT"; |
| 14 case KeyboardEvent.DOM_KEY_LOCATION_NUMPAD: | 14 case KeyboardEvent.DOM_KEY_LOCATION_NUMPAD: |
| 15 return "DOM_KEY_LOCATION_NUMPAD"; | 15 return "DOM_KEY_LOCATION_NUMPAD"; |
| 16 default: | 16 default: |
| 17 return "" + location | 17 return "" + location |
| 18 } | 18 } |
| 19 } | 19 } |
| 20 | 20 |
| 21 function keyevent(event) { | 21 function keyevent(event) { |
| 22 var p = document.createElement("p"); | 22 var p = document.createElement("p"); |
| 23 p.appendChild(document.createTextNode(event.type + " - key: " + event.keyIde
ntifier + "@" + keyLocationToText(event.location) + " (keyCode/charCode: " + eve
nt.keyCode + "/" + event.charCode + ")" + " modifiers: " + event.ctrlKey + "," +
event.altKey + "," + event.shiftKey + "," + event.metaKey)); | 23 p.appendChild(document.createTextNode(event.type + " - key: " + event.key +
"@" + keyLocationToText(event.location) + " (keyCode/charCode: " + event.keyCode
+ "/" + event.charCode + ")" + " modifiers: " + event.ctrlKey + "," + event.alt
Key + "," + event.shiftKey + "," + event.metaKey)); |
| 24 document.getElementById("result").appendChild(p); | 24 document.getElementById("result").appendChild(p); |
| 25 } | 25 } |
| 26 | 26 |
| 27 function init() { | 27 function init() { |
| 28 var input = document.getElementById("testinput"); | 28 var input = document.getElementById("testinput"); |
| 29 input.addEventListener("keydown", keyevent, true); | 29 input.addEventListener("keydown", keyevent, true); |
| 30 input.addEventListener("keypress", keyevent, true); | 30 input.addEventListener("keypress", keyevent, true); |
| 31 input.addEventListener("keyup", keyevent, true); | 31 input.addEventListener("keyup", keyevent, true); |
| 32 | 32 |
| 33 if (window.testRunner) | 33 if (window.testRunner) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 45 <form> | 45 <form> |
| 46 <input type="text" size="50" id="testinput" /> | 46 <input type="text" size="50" id="testinput" /> |
| 47 <input type="text" size="50" /> | 47 <input type="text" size="50" /> |
| 48 </form> | 48 </form> |
| 49 | 49 |
| 50 <p>This tests that DOMKeyboardEvents are created correctly in the JavaScript
API.</p> | 50 <p>This tests that DOMKeyboardEvents are created correctly in the JavaScript
API.</p> |
| 51 | 51 |
| 52 <div id="result"></div> | 52 <div id="result"></div> |
| 53 </body> | 53 </body> |
| 54 </html> | 54 </html> |
| OLD | NEW |