Skip to content

Commit

Permalink
Internal (engine): Use a common isArrowKeyCode implementation from …
Browse files Browse the repository at this point in the history
…`ckeditor5-utils` package. Closes #6648.
  • Loading branch information
mlewand authored Oct 13, 2020
2 parents eb73de3 + 2a4f9a1 commit 1ba5671
Showing 1 changed file with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import Observer from './observer';
import ViewSelection from '../selection';
import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
import { keyCodes, isArrowKeyCode } from '@ckeditor/ckeditor5-utils/src/keyboard';
import { debounce } from 'lodash-es';

/**
Expand Down Expand Up @@ -49,7 +49,7 @@ export default class FakeSelectionObserver extends Observer {
document.on( 'keydown', ( eventInfo, data ) => {
const selection = document.selection;

if ( selection.isFake && _isArrowKeyCode( data.keyCode ) && this.isEnabled ) {
if ( selection.isFake && isArrowKeyCode( data.keyCode ) && this.isEnabled ) {
// Prevents default key down handling - no selection change will occur.
data.preventDefault();

Expand Down Expand Up @@ -110,16 +110,3 @@ export default class FakeSelectionObserver extends Observer {
this._fireSelectionChangeDoneDebounced( data );
}
}

// Checks if one of the arrow keys is pressed.
//
// @private
// @param {Number} keyCode
// @returns {Boolean}
function _isArrowKeyCode( keyCode ) {
return keyCode == keyCodes.arrowright ||
keyCode == keyCodes.arrowleft ||
keyCode == keyCodes.arrowup ||
keyCode == keyCodes.arrowdown;
}

0 comments on commit 1ba5671

Please sign in to comment.