Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #172 from ckeditor/t/136
Browse files Browse the repository at this point in the history
Fix: Non-printable keys like volume up or the win key will not remove the content anymore. Closes #136.
  • Loading branch information
Reinmar committed Oct 31, 2018
2 parents e717ad1 + f96e999 commit 0ea9fbd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/utils/injectunsafekeystrokeshandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,26 @@ 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,
91, // Windows,
93, // Menu key,
144, // NumLock
145, // ScrollLock,
173, // Mute/Unmute
174, // Volume up
175, // Volume down,
176, // Next song,
177, // Previous song,
178, // Stop,
179, // Play/Pause,
255 // Display brightness (increase and decrease)
];

// Function keys.
Expand Down
10 changes: 10 additions & 0 deletions tests/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( '<paragraph>fo[ob]ar</paragraph>' );
} );
Expand Down

0 comments on commit 0ea9fbd

Please sign in to comment.