the-graph icon indicating copy to clipboard operation
the-graph copied to clipboard

Keybinding: ignore from input

Open astanciu opened this issue 8 years ago • 3 comments

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?

astanciu avatar Sep 05 '16 04:09 astanciu

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.

ifitzpatrick avatar Sep 09 '16 00:09 ifitzpatrick

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.

forresto avatar Sep 09 '16 13:09 forresto

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.

astanciu avatar Sep 09 '16 14:09 astanciu