Reputation: 4815
I'm developing a firefox addon. When trying to capture the keypress event I can see the output for it on my browser console. But not if I press CTRL + TAB for example:
window.addEventListener('load', function () {
document.addEventListener('keypress', function (e) {
console.error(e);
}, true);
}, false);
Output when pressing tab only:
keypress { target: <body.ask-page.new-topbar>, key: "Tab", charCode: 0, keyCode: 9 }
Why keypress doesn't triggers on any Ctrl combination?
Upvotes: 0
Views: 945
Reputation: 4815
To close this question: Here's my bug report including the fix which is the reason keypress don't get fired if Ctrl++ combination is pressed: https://bugzilla.mozilla.org/show_bug.cgi?id=1068282
Upvotes: 2
Reputation: 37328
As per my comment im not sure why e.ctlrKey
isn't true on keypress
.
What you can try getModifierState
window.addEventListener('load', function () {
document.addEventListener('keypress', function (e) {
console.error(e);
console.error('Control down:', e.getModifierState('Control'));
}, true);
}, false);
shows you can do this in keypress with getmodifier. works as long as you use ctrl as a modifier, meaning you press and hold ctrl first
Upvotes: 0