From f617da4096e990c304cb0da21db3550311868e52 Mon Sep 17 00:00:00 2001 From: chris-chao Date: Mon, 20 Aug 2018 23:52:36 -0500 Subject: [PATCH 1/2] [Ignore Keyboard Actions With Modifiers #60] ignore left/right arrow action triggers if user is holding down alt key --- src/components/KeyboardInteraction/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/KeyboardInteraction/index.ts b/src/components/KeyboardInteraction/index.ts index 7ba7b64..36d7351 100644 --- a/src/components/KeyboardInteraction/index.ts +++ b/src/components/KeyboardInteraction/index.ts @@ -32,12 +32,16 @@ class KeyboardInteractionInner extends Component { switch (e.code) { case 'ArrowLeft': case 'KeyH': - this.props.previousSong(); + if (!e.altKey){ + this.props.previousSong(); + } break; case 'ArrowRight': case 'KeyL': - this.props.nextSong(); + if (!e.altKey){ + this.props.nextSong(); + } break; case 'Space': From a06c95ac84b54c5d71757e5fb0c2d4d69ef330a0 Mon Sep 17 00:00:00 2001 From: chris-chao Date: Wed, 22 Aug 2018 12:40:17 -0500 Subject: [PATCH 2/2] Fix changes from code review --- src/components/KeyboardInteraction/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/KeyboardInteraction/index.ts b/src/components/KeyboardInteraction/index.ts index 36d7351..3b14056 100644 --- a/src/components/KeyboardInteraction/index.ts +++ b/src/components/KeyboardInteraction/index.ts @@ -29,19 +29,19 @@ class KeyboardInteractionInner extends Component { return; // Do nothing if the event was already processed } + if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) { + return; + } + switch (e.code) { case 'ArrowLeft': case 'KeyH': - if (!e.altKey){ - this.props.previousSong(); - } + this.props.previousSong(); break; case 'ArrowRight': case 'KeyL': - if (!e.altKey){ - this.props.nextSong(); - } + this.props.nextSong(); break; case 'Space':