diff --git a/editor/block-toolbar/index.js b/editor/block-toolbar/index.js index 7e57b5ff2ddfb..a0489be8e7e93 100644 --- a/editor/block-toolbar/index.js +++ b/editor/block-toolbar/index.js @@ -24,7 +24,7 @@ import BlockRightMenu from '../block-settings-menu'; /** * Module Constants */ -const { LEFT, RIGHT, ESCAPE, ALT } = keycodes; +const { LEFT, RIGHT, ESCAPE, F10, isMetaKey } = keycodes; function FirstChild( { children } ) { const childrenArray = Children.toArray( children ); @@ -72,7 +72,7 @@ class BlockToolbar extends Component { const tabbables = focus.tabbable.find( this.toolbar ); const indexOfTabbable = tabbables.indexOf( document.activeElement ); - if ( event.keyCode === ALT ) { + if ( isMetaKey( event.keyCode ) || ( event.keyCode === F10 && event.altKey ) ) { if ( tabbables.length ) { tabbables[ 0 ].focus(); } diff --git a/utils/keycodes.js b/utils/keycodes.js index c3d63bb678c8c..9488cf4e595e5 100644 --- a/utils/keycodes.js +++ b/utils/keycodes.js @@ -1,6 +1,7 @@ export const BACKSPACE = 8; export const TAB = 9; export const ENTER = 13; +export const CTRL = 17; export const ALT = 18; export const ESCAPE = 27; export const SPACE = 32; @@ -9,3 +10,20 @@ export const UP = 38; export const RIGHT = 39; export const DOWN = 40; export const DELETE = 46; + +export const F10 = 121; + +export const MAC_RIGHT = 93; +export const MAC_LEFT = 91; +export const MAC_FIREFOX = 224; + +function isMac() { + return window.navigator.platform.toLowerCase().indexOf( 'mac' ) !== -1; +} + +export function isMetaKey( keyCode ) { + return isMac() + // The keyCode depends on the browser and the left/right might be different + ? [ MAC_FIREFOX, MAC_LEFT, MAC_RIGHT ].indexOf( keyCode ) !== -1 + : CTRL; +}