Skip to content

Commit

Permalink
Merge pull request #1826 from WordPress/fix/1640-list-block-add-keybo…
Browse files Browse the repository at this point in the history
…ard-shortcuts

Add shortcut keys for indenting and outdenting lists to the list block
  • Loading branch information
tiny-james authored Jul 12, 2017
2 parents bb3094e + e622210 commit 55cf757
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions blocks/library/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ registerBlockType( 'core/list', {
} );
} );

// this checks for languages that do not typically have square brackets on their keyboards
const lang = window.navigator.browserLanguage || window.navigator.language;
const keyboardHasSqBracket = ! /^(?:fr|nl|sv|ru|de|es|it)/.test( lang );

if ( keyboardHasSqBracket ) {
// keycode 219 = '[' and keycode 221 = ']'
editor.shortcuts.add( 'meta+219', 'Decrease indent', 'Outdent' );
editor.shortcuts.add( 'meta+221', 'Increase indent', 'Indent' );
} else {
editor.shortcuts.add( 'meta+shift+m', 'Decrease indent', 'Outdent' );
editor.shortcuts.add( 'meta+m', 'Increase indent', 'Indent' );
}

this.editor = editor;
}

Expand Down

0 comments on commit 55cf757

Please sign in to comment.