the-graph
the-graph copied to clipboard
Keybinding: ignore from input
I noticed there was a recent (Julyish '16) merge of some new keybindings: https://github.com/the-grid/the-graph/blob/master/the-graph/the-graph-app.js#L398
Won't these get triggered anytime there is input in any ? Would the right way to handle this be to catch that input on and preventDefault there?
Yeah the hot keys should be able to get triggered anywhere on the page. If you have forms with inputs you can capture the keydown event and event.stopPropagation() there. Not sure if there is a better way to handle it than that since we want the hotkeys to trigger anywhere on the page unless there is an input of some sort focused.
I think the more-correct solution is to check the event.target
in the keybinding code, and ignore if it is coming from an input, textarea, contenteditable.
Actually, that's what I ended up doing. But for some reason, not sure if it's something I'm doing, but for me event.target
is never the actual input, but its container.