piranha / keymage

Yet Another JS Keybinding library
ISC License
332 stars 31 forks source link

Disable while text field is focused? #14

Open timhettler opened 8 years ago

timhettler commented 8 years ago

Is there an easy way to globally disable keymage while an INPUT or TEXTAREA is focused?

piranha commented 8 years ago

Not really right now, no, but I would love to see a contribution!

How do you imagine this to work? I guess it's not worth it enabling it for everyone, plus this will break users of library... Maybe an opt-in process, call keymage.preventOnInput() to do that? Any other ideas?

orbitbot commented 8 years ago

Would this work by attaching the default keyhandlers to a specific scope and enable/disable those with the input/textarea focus and blur events?

piranha commented 8 years ago

Sure, it will, if a bit inconveniently. :) I remember someone (keymaster maybe?) disabling all hotkeys on inputs, but that was one of the reasons I wrote this library - I needed hotkeys working while editing textarea.

dustingetz commented 7 years ago

Can we unregister listeners in nested scopes?

keymage('a', 'shift ?', function() { ... }); // capture ? keymage('a', 'myTextInput', 'shift ?', undefined); // in a text scope so let it through

piranha commented 7 years ago

I love this idea! If you're up to implementing that, you're very welcome! If not, I guess I'll get to that sooner or later, but no real estimates right now, sorry. :)