How to disable Windows keys (logo key and menu key) using Javascript -
i write javascript code doesn't disable 2 windows keys (i mean logo key , menu key), though:
document.onkeydown = function(e) { document.title = e.keycode; if (e.keycode == 91 || e.keycode == 93) { window.event.keycode = 0; window.event.returnvalue = false; return false; } };
the 2 window.xxx statements not necessary add them in buy insurance (just doubt e doesn't totally equal window.event).
so i'd ask question: " there feasible way, directly or indirectly, job in javascript? "
your code looks right, try find out real keycodes simple script:
document.onkeydown = checkkeycode function checkkeycode(e) { var keycode; if (window.event) keycode = window.event.keycode; else if (e) keycode = e.which; alert("keycode: " + keycode); }
and disabel keys modify function (example 'enter'):
document.onkeydown = checkkeycode function checkkeycode(e) { var event = e || window.event; var keycode = event.which || event.keycode; if (keycode == 13) { // return key pressed } }
Comments
Post a Comment