KeyboardEvent.location.html (2327B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <title id='desc'> KeyboardEvent.location </title> 5 <script type="text/javascript"> 6 var PassTest = function() 7 { 8 document.getElementById("testresult").firstChild.data = "PASS"; 9 } 10 11 var FailTest = function() 12 { 13 document.getElementById("testresult").firstChild.data = "FAIL"; 14 } 15 16 var EVENT = "keydown"; 17 var TARGET; 18 var ExpectResult = ["a", 0, "Control", 1, "Shift", 2]; 19 var ActualResult = []; 20 21 window.onload = function(e) 22 { 23 try 24 { 25 TARGET = document.getElementById("target"); 26 TARGET.addEventListener(EVENT, TestEvent, true); 27 } 28 catch(ex) 29 { 30 FailTest(); 31 } 32 } 33 34 function TestEvent(evt) 35 { 36 ActualResult.push(evt.key, evt.location); 37 38 if ((evt.type == EVENT) && (evt.key == "Shift")) 39 { 40 if (ExpectResult.toString() == ActualResult.toString()) 41 { 42 PassTest(); 43 } 44 else 45 { 46 FailTest(); 47 } 48 TARGET.removeEventListener(EVENT, TestEvent, true); 49 } 50 } 51 </script> 52 </head> 53 <body> 54 <h3>DOM Events</h3> 55 <h4> 56 Test Description: KeyboardEvent.location attribute contains an indication of the 57 location of the key on the device. 58 </h4> 59 60 <pre> 61 <input id="target" value=""/> 62 63 Steps: 64 1) Type 'a' in the above textbox using keyboard 65 2) Press '{CTRL}' key on the left side of the keyboard 66 3) Press '{SHIFT}' key on the right side of the keyboard 67 4) <a href="KeyboardEvent.location.html">Click here</a> to test again if not following the steps exactly 68 </pre> 69 70 <p>Test passes if the word "PASS" appears below after following the above steps.</p> 71 <div>Test result: </div> 72 <div id='testresult'>FAIL</div> 73 </body> 74 </html>