core icon indicating copy to clipboard operation
core copied to clipboard

fix(plugin-search): triggering hotkey while typing

Open kleinfreund opened this issue 3 years ago • 2 comments

Changes

Fixes an issue with the search plugin’s hotkey being triggered while typing into a text control (e.g. when setting the shortcut to / and then trying to type / into an input[type=text]).

Notes

This added logic is probably not entirely complete and accurate. It would probably be more accurate to only check input elements of certain types for example, but I think this should not cause issues.

kleinfreund avatar Oct 10 '22 13:10 kleinfreund

Actually, the interface for hotKeys is our solution dealing with these situations.

If you have inputs in your site, you probably should not set hotkey with a single key without ctrl alt or shift

Mister-Hope avatar Oct 10 '22 13:10 Mister-Hope

I don’t think avoiding this sort of conflict should be left to consuming projects. Yes, perhaps single-letter shortcuts aren’t the best idea, but they shouldn’t be ruled out because another tool makes that impossible.

That being said, relying on modifiers to avoid conflicts isn’t as reliable as it seems because several characters are typed while holding down a modifier (most commonly shift). This gets more complex with the wide variety of keyboard layouts in the mix. For example, Shift+1 produces ! on ANSI US keyboard layouts. Let’s say Shift+1 is used as the search plugin hotkey. The issue will now reproduce when trying to type !.

Maybe the majority of such conflicts are very unlikely, but the search plugin could just avoid them by not triggering while the user is typing (which in absence of this particular information would have to be “text control is focused”).

kleinfreund avatar Oct 10 '22 13:10 kleinfreund