frend/frend.co

Test for modifier when listening to key events

Closed this issue · 7 comments

I would expect the components not to swallow key events with modifiers like Alt+ArrowLeft for history back.

Good point, thanks @waldbaerkoch. We'll look into a cross-platform/browser fix for this and make sure we're not catching unnecessary key events.

Added modifier guard clauses in the keydown handlers for altKey and metaKey. In fix branch commit c44af13

Is this condition too simplistic? Keeps it concise without getting into getModifierState territory.

let isModifierKey = (e.metaKey || e.altKey) ? true : false;
if (isModifierKey) return;

Will do more cross-browser testing, and open to alternative approaches.

Just reread that and realised the ternary statement is redundant. Will refactor. 😴

Tested the above approach in Chrome/FF/IE on Windows and Chrome/Safari on Mac. I'm happy it's resolved the issue.

@thomasdigby, @waldbaerkoch - are you aware of a better approach for this key event side-effect?

I think, that is an appropriate solution. Thanks.

Merge away 🏌

Closed with #77