/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function trap(e) { if (!e) { e = event; e.which = e.keyCode; } try { modifierKey = e.ctrlKey || e.altKey || e.metaKey; } catch(e) { modifierKey = false; } return modifierKey || e.which == 0; } function keys(key) { if (!key) { key = event; key.which = key.keyCode; } if (key.which == 84) { //toggle(); return; } switch (key.which) { case 32: // spacebar case 34: // page down case 39: // rightkey case 40: // downkey // Do something break; case 33: // page up case 37: // leftkey case 38: // upkey // Do something break; case 36: // home // Do something break; case 35: // end // Do something break; case 27: // escape case 81: // q // Do something break; } return false; } function keyCap() { document.onkeypress = trap; document.onkeyup = keys; }
URL: http://rmhh.co.uk/ascii.html