jquery - ALT followed by Q (custome shortcut) is not working with browser in javascript -
i trying implement keyboard shortcut application. want use alt + q combination. however, when try run code , press alt key, sets focus on browsers menu bar control , fails.
i tried stop event propagation several methods like,
function keydowneventhandler() { if (event.keycode == 18) { //stop code } } stoppropagation(event); canclebubbling(); return false; event.preventdefault();
still behaves way.
edit - actually problem not detection. when user press alt key , release , q key pressed after that, highlights browser menu. doesn't call function custom shortcut.
is default behaviour of browser ? can override ?
please in same.
thanks
update
here fiddle detecting "alt+q" sequence:
document.onkeydown = keycheck; var previouskeycode = 0; function keycheck(e) { var keyid = (window.event) ? event.keycode : e.keycode; switch (keyid) { case 18: previouskeycode = 18; break; case 81: if (previouskeycode == 18) { alert("alt+q pressed!!!") } previouskeycode=keyid; break; default: previouskeycode=keyid; } }
Comments
Post a Comment