piranha/keymage

Disable while text field is focused?

Opened this issue · 5 comments

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

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?

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

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.

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

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. :)