Firefox handles Ctrl+number shortcut before keypress fired


(Ru Kom) #1

I have keypress handler for Ctrl+number shortcuts in content script. It has event.preventDefault() and worked well not so long ago. But now browser doesn’t fire it and just do it’s default deed - switches tabs. keydown still works though. I made no updates - it happened suddenly. I found no info why.

UPD: I mean situation when Ctrl is held and I press any number.


(Martin Giger) #2

Sounds like https://developer.mozilla.org/en-US/docs/Web/Events/keypress#Browser_compatibility. As the top of that page mentions, you should use a different event like keydown or up.

Ctrl + 1 doesn’t produce a printable value, thus no event is fired.