license /**
 * KEY provides normalized string values for keys.
 */ export const KEY = { UNKNOWN : 'Unknown' , BACKSPACE : 'Backspace' , ENTER : 'Enter' , SPACEBAR : 'Spacebar' , PAGE_UP : 'PageUp' , PAGE_DOWN : 'PageDown' , END : 'End' , HOME : 'Home' , ARROW_LEFT : 'ArrowLeft' , ARROW_UP : 'ArrowUp' , ARROW_RIGHT : 'ArrowRight' , ARROW_DOWN : 'ArrowDown' , DELETE : 'Delete' , ESCAPE : 'Escape' , TAB : 'Tab' , } ; const normalizedKeys = new Set < string > ( ) ; normalizedKeys . add ( KEY . BACKSPACE ) ; normalizedKeys . add ( KEY . ENTER ) ; normalizedKeys . add ( KEY . SPACEBAR ) ; normalizedKeys . add ( KEY . PAGE_UP ) ; normalizedKeys . add ( KEY . PAGE_DOWN ) ; normalizedKeys . add ( KEY . END ) ; normalizedKeys . add ( KEY . HOME ) ; normalizedKeys . add ( KEY . ARROW_LEFT ) ; normalizedKeys . add ( KEY . ARROW_UP ) ; normalizedKeys . add ( KEY . ARROW_RIGHT ) ; normalizedKeys . add ( KEY . ARROW_DOWN ) ; normalizedKeys . add ( KEY . DELETE ) ; normalizedKeys . add ( KEY . ESCAPE ) ; normalizedKeys . add ( KEY . TAB ) ; const KEY_CODE = { BACKSPACE : 8 , ENTER : 13 , SPACEBAR : 32 , PAGE_UP : 33 , PAGE_DOWN : 34 , END : 35 , HOME : 36 , ARROW_LEFT : 37 , ARROW_UP : 38 , ARROW_RIGHT : 39 , ARROW_DOWN : 40 , DELETE : 46 , ESCAPE : 27 , TAB : 9 , } ; const mappedKeyCodes = new Map < number , string > ( ) ; mappedKeyCodes . set ( KEY_CODE . BACKSPACE , KEY . BACKSPACE ) ; mappedKeyCodes . set ( KEY_CODE . ENTER , KEY . ENTER ) ; mappedKeyCodes . set ( KEY_CODE . SPACEBAR , KEY . SPACEBAR ) ; mappedKeyCodes . set ( KEY_CODE . PAGE_UP , KEY . PAGE_UP ) ; mappedKeyCodes . set ( KEY_CODE . PAGE_DOWN , KEY . PAGE_DOWN ) ; mappedKeyCodes . set ( KEY_CODE . END , KEY . END ) ; mappedKeyCodes . set ( KEY_CODE . HOME , KEY . HOME ) ; mappedKeyCodes . set ( KEY_CODE . ARROW_LEFT , KEY . ARROW_LEFT ) ; mappedKeyCodes . set ( KEY_CODE . ARROW_UP , KEY . ARROW_UP ) ; mappedKeyCodes . set ( KEY_CODE . ARROW_RIGHT , KEY . ARROW_RIGHT ) ; mappedKeyCodes . set ( KEY_CODE . ARROW_DOWN , KEY . ARROW_DOWN ) ; mappedKeyCodes . set ( KEY_CODE . DELETE , KEY . DELETE ) ; mappedKeyCodes . set ( KEY_CODE . ESCAPE , KEY . ESCAPE ) ; mappedKeyCodes . set ( KEY_CODE . TAB , KEY . TAB ) ; const navigationKeys = new Set < string > ( ) ; navigationKeys . add ( KEY . PAGE_UP ) ; navigationKeys . add ( KEY . PAGE_DOWN ) ; navigationKeys . add ( KEY . END ) ; navigationKeys . add ( KEY . HOME ) ; navigationKeys . add ( KEY . ARROW_LEFT ) ; navigationKeys . add ( KEY . ARROW_UP ) ; navigationKeys . add ( KEY . ARROW_RIGHT ) ; navigationKeys . add ( KEY . ARROW_DOWN ) ; /**
 * normalizeKey returns the normalized string for a navigational action.
 */ export function normalizeKey ( evt ) { const { key } = evt ; if ( normalizedKeys . has ( key ) ) { return key ; } const mappedKey = mappedKeyCodes . get ( evt . keyCode ) ; if ( mappedKey ) { return mappedKey ; } return KEY . UNKNOWN ; } /**
 * isNavigationEvent returns whether the event is a navigation event
 */ export function isNavigationEvent ( evt ) { return navigationKeys . has ( normalizeKey ( evt ) ) ; }