From 7a5e8f1f2a12dca91465c07f3e703be316b3a6c7 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Tue, 16 Oct 2018 11:02:44 +0200 Subject: [PATCH 1/2] Added Windows Media Keys to safe key codes list. --- src/utils/injectunsafekeystrokeshandling.js | 11 ++++++++++- tests/input.js | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/utils/injectunsafekeystrokeshandling.js b/src/utils/injectunsafekeystrokeshandling.js index a6f38d1..765f80c 100644 --- a/src/utils/injectunsafekeystrokeshandling.js +++ b/src/utils/injectunsafekeystrokeshandling.js @@ -123,12 +123,21 @@ const safeKeycodes = [ 16, // Shift 17, // Ctrl 18, // Alt + 19, // Pause 20, // CapsLock 27, // Escape 33, // PageUp 34, // PageDown 35, // Home - 36 // End + 36, // End, + 45, // Insert, + 173, // Mute/Unmute + 174, // Volume up + 175, // Volume down, + 176, // Next song, + 177, // Previous song, + 179, // Play/Stop, + 255 // Display brightness (increase and decrease) ]; // Function keys. diff --git a/tests/input.js b/tests/input.js index 2cdaf8b..975c259 100644 --- a/tests/input.js +++ b/tests/input.js @@ -644,8 +644,18 @@ describe( 'Input feature', () => { } ); viewDocument.fire( 'keydown', { keyCode: 16 } ); // Shift + viewDocument.fire( 'keydown', { keyCode: 19 } ); // Pause viewDocument.fire( 'keydown', { keyCode: 35 } ); // Home viewDocument.fire( 'keydown', { keyCode: 112 } ); // F1 + viewDocument.fire( 'keydown', { keyCode: 255 } ); // Display brightness + + // Media control keys + viewDocument.fire( 'keydown', { keyCode: 173 } ); // Mute + viewDocument.fire( 'keydown', { keyCode: 174 } ); // Volume up + viewDocument.fire( 'keydown', { keyCode: 175 } ); // Volume down + viewDocument.fire( 'keydown', { keyCode: 176 } ); // Next song + viewDocument.fire( 'keydown', { keyCode: 177 } ); // Previous song + viewDocument.fire( 'keydown', { keyCode: 179 } ); // Stop expect( getModelData( model ) ).to.equal( 'fo[ob]ar' ); } ); From 248041386679cf59bb978a72c95dc76c4b46a2c5 Mon Sep 17 00:00:00 2001 From: Kamil Piechaczek Date: Tue, 30 Oct 2018 10:18:21 +0100 Subject: [PATCH 2/2] Added more safe keys. --- src/utils/injectunsafekeystrokeshandling.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/injectunsafekeystrokeshandling.js b/src/utils/injectunsafekeystrokeshandling.js index 765f80c..754489c 100644 --- a/src/utils/injectunsafekeystrokeshandling.js +++ b/src/utils/injectunsafekeystrokeshandling.js @@ -131,12 +131,17 @@ const safeKeycodes = [ 35, // Home 36, // End, 45, // Insert, + 91, // Windows, + 93, // Menu key, + 144, // NumLock + 145, // ScrollLock, 173, // Mute/Unmute 174, // Volume up 175, // Volume down, 176, // Next song, 177, // Previous song, - 179, // Play/Stop, + 178, // Stop, + 179, // Play/Pause, 255 // Display brightness (increase and decrease) ];