I’ve defined some global keyboard handling using jQuery’s keypress event.
Is there a way to suppress these events for input/textarea fields so as not to interfere with typing?
I’ve used some hacks with conditions based on element selectors, but those had a big performance impact as they were fired on every single keypress.
(Some of those fields are created dynamically, which is beyond my control – perhaps that’s relevant.)
Create an onfocus handler for all input and textareas that sets some global variable indicating that keyboard events should be ignored. Create another handler for the blur event to reset the global variable.
In your key handlers you would just have to check if the value is true or not, and return if it is true.