javascript - A simple e.altKey test -
summary:
i want grab event of alt + z onkeypress. using e.altkey accomplish this. however, isn't working anywhere, textareas inputs div[contenteditable]s!
fiddle
the event of shift + any_key (any_key !== alt) works fine, alt isn't detected @ all. tested keydown, works perfectly.
i don't know if related, ctrl key doesn't work in fiddle. have seen ctrl key beingness caught onkeypress in various answers one: http://stackoverflow.com/a/4604093/2675672 , have 0 thought why doesn't work in fiddle.
by not working, mean that, no alert boxes pop up.
it must simple might overlooking.
also, have 1 more query, e.altkey observe option key press in apple macs ?
note: chrome back upwards required, without libraries. also, alt key isn't broken. can press alt + f , open file menu in chrome fine.
edit:
so, realized chrome bug event doesn't fire (noticed @pointy). still, if has workarounds making work. please share them. thanks!
onkeypress doesn't fire keys.
you need utilize onkeydown.
note: onkeypress event not fired keys (e.g. alt, ctrl, shift, esc) in browsers. observe whether user has pressed key, utilize onkeydown event instead, because works keys.
quote from: http://www.w3schools.com/jsref/event_onkeypress.asp
javascript html keyboard key keypress
No comments:
Post a Comment