Skip to content

Commit

Permalink
Merge pull request #16134 from ckeditor/cc/6043-pagination-obscurs-focus
Browse files Browse the repository at this point in the history
Feature (utils): Added Page Up and Page Down keys to the keyboard utilities (`keyCodes`, `getEnvKeystrokeText()`).
  • Loading branch information
niegowski authored Apr 2, 2024
2 parents 45a4a8e + 28f4b88 commit 0c64f2a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/ckeditor5-utils/src/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ const keyCodesToGlyphs: { [key: number]: string } = {
38: '↑',
39: '→',
40: '↓',
9: '⇥'
9: '⇥',
33: 'Page Up',
34: 'Page Down'
} as const;

/**
Expand Down Expand Up @@ -245,6 +247,8 @@ export function isForwardArrowKeyCode(

function generateKnownKeyCodes(): { readonly [ keyCode: string ]: number } {
const keyCodes: { [keyCode: string]: number } = {
pageup: 33,
pagedown: 34,
arrowleft: 37,
arrowup: 38,
arrowright: 39,
Expand Down
10 changes: 10 additions & 0 deletions packages/ckeditor5-utils/tests/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ describe( 'Keyboard', () => {
expect( keyCodes.z ).to.equal( 90 );
} );

it( 'contains page up and down keys', () => {
expect( keyCodes.pageup ).to.equal( 33 );
expect( keyCodes.pagedown ).to.equal( 34 );
} );

it( 'modifiers and other keys', () => {
expect( keyCodes.delete ).to.equal( 46 );
expect( keyCodes.ctrl ).to.equal( 0x110000 );
Expand Down Expand Up @@ -308,6 +313,11 @@ describe( 'Keyboard', () => {
expect( getEnvKeystrokeText( 'Arrowright' ) ).to.equal( '→' );
expect( getEnvKeystrokeText( 'Arrowdown' ) ).to.equal( '↓' );
} );

it( 'uses human readable labels for Page up and Page down', () => {
expect( getEnvKeystrokeText( 'pageup' ) ).to.equal( 'Page Up' );
expect( getEnvKeystrokeText( 'pagedown' ) ).to.equal( 'Page Down' );
} );
} );

describe( 'on iOS', () => {
Expand Down

0 comments on commit 0c64f2a

Please sign in to comment.