// This function alerts a string of keys that the user has typed function showKeys() { if (keys != '') { alert('You have typed: ' + keys); window.status = keys = ''; } else { alert('You have to type some keys first.'); } }
// This function displays the keys pressed in the status bar function showXY(ev) { if (document.all) { ev = event; } window.status = 'X: ' + ev.screenX + ' Y: ' + ev.screenY; }
// This function captures the keys pressed one at a time function keepKeys(ev) { if (document.layers) { keys += String.fromCharCode(ev.which); window.status = 'Key pressed: ' + String.fromCharCode(ev.which); } else { keys += String.fromCharCode(event.keyCode); window.status = 'Key pressed: ' + String.fromCharCode(event.keyCode); } }
</HEAD> <BODY BGCLOR=WHITE> Click your mouse button, then move it around, click again to stop tracking. <BR><BR><BR><BR><BR><BR> Now type some keys.... any keys. Then press <B>Show Keys</B><BR> <FORM><INPUT TYPE=BUTTON VALUE="Show Keys" onClick="showKeys();"></FORM> </BODY> </HTML>
Related Scripts with Example Source Code in same category :