Skip to content

Commit

Permalink
displayShortcut capitalizes provided key (e.g. Del instead of DEL)
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Jul 31, 2018
1 parent faea1dc commit ef530a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/keycodes/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* External dependencies
*/
import { get, mapValues, includes } from 'lodash';
import { get, mapValues, includes, capitalize } from 'lodash';

export const BACKSPACE = 8;
export const TAB = 9;
Expand Down Expand Up @@ -81,7 +81,7 @@ export const displayShortcut = mapValues( modifiers, ( modifier ) => {
};
const shortcut = [
...modifier( _isMac ).map( ( key ) => get( replacementKeyMap, key, key ) ),
character.toUpperCase(),
capitalize( character ),
].join( '+' );

// Because we use just the clover symbol for MacOS's "command" key, remove
Expand Down
4 changes: 2 additions & 2 deletions packages/keycodes/src/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe( 'displayShortcut', () => {

it( 'outputs command+Del on MacOS (when the provided key is not a single character)', () => {
const shortcut = displayShortcut.primary( 'del', isMacOSTrue );
expect( shortcut ).toEqual( '⌘+DEL' );
expect( shortcut ).toEqual( '⌘+Del' );
} );
} );

Expand All @@ -41,7 +41,7 @@ describe( 'displayShortcut', () => {

it( 'outputs shift+command+Del on MacOS (when the provided key is not a single character)', () => {
const shortcut = displayShortcut.primaryShift( 'del', isMacOSTrue );
expect( shortcut ).toEqual( 'Shift+⌘+DEL' );
expect( shortcut ).toEqual( 'Shift+⌘+Del' );
} );
} );

Expand Down

0 comments on commit ef530a9

Please sign in to comment.