Przeglądaj źródła

Added tab and esc to keyCodes. Fixes #83.

Piotrek Koszuliński 9 lat temu
rodzic
commit
252b15861a

+ 3 - 1
packages/ckeditor5-utils/src/keyboard.js

@@ -20,7 +20,7 @@ import env from './env.js';
  * * `a-z`,
  * * `0-9`,
  * * `arrow(left|up|right|bottom)`,
- * * `backspace`, `delete`, `enter`,
+ * * `backspace`, `delete`, `enter`, `esc`, `tab`,
  * * `ctrl`, `cmd`, `shift`, `alt`.
  *
  * @member {Object} utils.keyboard.keyCodes
@@ -120,6 +120,8 @@ function generateKnownKeyCodes() {
 		backspace: 8,
 		delete: 46,
 		enter: 13,
+		esc: 27,
+		tab: 9,
 
 		// The idea about these numbers is that they do not collide with any real key codes, so we can use them
 		// like bit masks.

+ 6 - 0
packages/ckeditor5-utils/tests/keyboard.js

@@ -23,6 +23,12 @@ describe( 'Keyboard', () => {
 			expect( keyCodes.delete ).to.equal( 46 );
 			expect( keyCodes.ctrl ).to.equal( 0x110000 );
 			expect( keyCodes.cmd ).to.equal( 0x110000 );
+
+			expect( keyCodes ).to.include.keys(
+				'ctrl', 'cmd', 'shift', 'alt',
+				'arrowleft', 'arrowup', 'arrowright', 'arrowdown',
+				'backspace', 'delete', 'enter', 'esc', 'tab'
+			);
 		} );
 	} );