/**
 * An object which represents an abstract keyboard layout.
 */ export interface IKeyboardLayout { /**
     * The human readable name of the layout.
     *
     * This value is used primarily for display and debugging purposes.
     */ readonly name : string ; returns keys ( ) : string [ ] ; param key returns isValidKey ( key ) : boolean ; param key returns isModifierKey ( key ) : boolean ; param event returns keyForKeydownEvent ( event ) : string ; } returns export function getKeyboardLayout ( ) { return Private . keyboardLayout ; } param export function setKeyboardLayout ( layout ) { Private . keyboardLayout = layout ; } /**
 * A concrete implementation of [[IKeyboardLayout]] based on keycodes.
 *
 * The `keyCode` property of a `'keydown'` event is a browser and OS
 * specific representation of the physical key (not character) which
 * was pressed on a keyboard. While not the most convenient API, it
 * is currently the only one which works reliably on all browsers.
 *
 * This class accepts a user-defined mapping of keycode to key, which
 * allows for reliable shortcuts tailored to the user's system.
 */ export class KeycodeLayout implements IKeyboardLayout { param name param codes param modifierKeys constructor ( name , codes , modifierKeys = [ ] ) { this . name = name ; this . _codes = codes ; this . _keys = KeycodeLayout . extractKeys ( codes ) ; this . _modifierKeys = KeycodeLayout . convertToKeySet ( modifierKeys ) ; } /**
     * The human readable name of the layout.
     */ readonly name : string ; returns keys ( ) { return Object . keys ( this . _keys ) ; } param key returns isValidKey ( key ) { return key in this . _keys ; } param key returns isModifierKey ( key ) { return key in this . _modifierKeys ; } param event returns keyForKeydownEvent ( event ) { return this . _codes [ event . keyCode ] || '' ; } private _keys : KeycodeLayout . KeySet ; private _codes : KeycodeLayout . CodeMap ; private _modifierKeys : KeycodeLayout . KeySet ; } /**
 * The namespace for the `KeycodeLayout` class statics.
 */ export namespace KeycodeLayout { /**
     * A type alias for a keycode map.
     */ export type CodeMap = { readonly [ code ] : string ; } ; /**
     * A type alias for a key set.
     */ export type KeySet = { readonly [ key ] : boolean ; } ; param code returns export function extractKeys ( codes ) { let keys = Object . create ( null ) ; for ( let c in codes ) { keys [ codes [ c ] ] = true ; } return keys as KeySet ; } param keys returns export function convertToKeySet ( keys ) { let keySet = Object ( null ) ; for ( let i = 0 , n = keys . length ; i < n ; ++ i ) { keySet [ keys [ i ] ] = true ; } return keySet ; } } /**
 * A keycode-based keyboard layout for US English keyboards.
 *
 * This layout is valid for the following OS/Browser combinations.
 *
 * - Windows
 *   - Chrome
 *   - Firefox
 *   - IE
 *
 * - OSX
 *   - Chrome
 *   - Firefox
 *   - Safari
 *
 * - Linux
 *   - Chrome
 *   - Firefox
 *
 * Other combinations may also work, but are untested.
 */ export const EN_US = new KeycodeLayout ( 'en-us' , { 8 : 'Backspace' , 9 : 'Tab' , 13 : 'Enter' , 16 : 'Shift' , 17 : 'Ctrl' , 18 : 'Alt' , 19 : 'Pause' , 27 : 'Escape' , 32 : 'Space' , 33 : 'PageUp' , 34 : 'PageDown' , 35 : 'End' , 36 : 'Home' , 37 : 'ArrowLeft' , 38 : 'ArrowUp' , 39 : 'ArrowRight' , 40 : 'ArrowDown' , 45 : 'Insert' , 46 : 'Delete' , 48 : '0' , 49 : '1' , 50 : '2' , 51 : '3' , 52 : '4' , 53 : '5' , 54 : '6' , 55 : '7' , 56 : '8' , 57 : '9' , 59 : ';' , 61 : '=' , 65 : 'A' , 66 : 'B' , 67 : 'C' , 68 : 'D' , 69 : 'E' , 70 : 'F' , 71 : 'G' , 72 : 'H' , 73 : 'I' , 74 : 'J' , 75 : 'K' , 76 : 'L' , 77 : 'M' , 78 : 'N' , 79 : 'O' , 80 : 'P' , 81 : 'Q' , 82 : 'R' , 83 : 'S' , 84 : 'T' , 85 : 'U' , 86 : 'V' , 87 : 'W' , 88 : 'X' , 89 : 'Y' , 90 : 'Z' , 91 : 'Meta' , 93 : 'ContextMenu' , 96 : '0' , 97 : '1' , 98 : '2' , 99 : '3' , 100 : '4' , 101 : '5' , 102 : '6' , 103 : '7' , 104 : '8' , 105 : '9' , 106 : '*' , 107 : '+' , 109 : '-' , 110 : '.' , 111 : '/' , 112 : 'F1' , 113 : 'F2' , 114 : 'F3' , 115 : 'F4' , 116 : 'F5' , 117 : 'F6' , 118 : 'F7' , 119 : 'F8' , 120 : 'F9' , 121 : 'F10' , 122 : 'F11' , 123 : 'F12' , 173 : '-' , 186 : ';' , 187 : '=' , 188 : ',' , 189 : '-' , 190 : '.' , 191 : '/' , 192 : '`' , 219 : '[' , 220 : '\\' , 221 : ']' , 222 : "'" , 224 : 'Meta' } , [ 'Shift' , 'Ctrl' , 'Alt' , 'Meta' ] ) ; /**
 * The namespace for the module implementation details.
 */ namespace Private { /**
     * The global keyboard layout instance.
     */ export let keyboardLayout = EN_US ; }