const Keys = { Unidentified : "Unidentified" , ArrowDown : "ArrowDown" , ArrowLeft : "ArrowLeft" , ArrowRight : "ArrowRight" , ArrowUp : "ArrowUp" , Home : "Home" , End : "End" , PageDown : "PageDown" , PageUp : "PageUp" , Escape : "Escape" , Enter : "Enter" , Space : " " } ; function identifyKeyFromEvent ( event ) { const key = event . key ; const keyIdentifier = event . keyIdentifier ; const location = event . location ; if ( key === Keys . ArrowDown || key === "Down" || keyIdentifier === "Down" ) { if ( event . metaKey ) { return Keys . End ; } return Keys . ArrowDown ; } else if ( key === Keys . ArrowLeft || key === "Left" || keyIdentifier === "Left" ) { return Keys . ArrowLeft ; } else if ( key === Keys . ArrowRight || key === "Right" || keyIdentifier === "Right" ) { return Keys . ArrowRight ; } else if ( key === Keys . ArrowUp || key === "Up" || keyIdentifier === "Up" ) { if ( event . metaKey ) { return Keys . Home ; } return Keys . ArrowUp ; } else if ( key === Keys . Escape || key === "Esc" || keyIdentifier === "U+001B" ) { return Keys . Escape ; } else if ( key === Keys . Enter || keyIdentifier === "Enter" ) { return Keys . Enter ; } else if ( key === Keys . Space || keyIdentifier === "U+0020" ) { return Keys . Space ; } else if ( key === "0" || keyIdentifier === "U+0030" ) { return "0" ; } else if ( key === "+" || key === "Add" || keyIdentifier === "U+002B" || keyIdentifier === "U+00BB" || ( keyIdentifier === "U+004B" && location === KeyboardEvent . DOM_KEY_LOCATION_NUMPAD ) ) { return "+" ; } else if ( key === "-" || key === "Subtract" || keyIdentifier === "U+002D" || keyIdentifier === "U+00BD" || ( keyIdentifier === "U+004D" && location === KeyboardEvent . DOM_KEY_LOCATION_NUMPAD ) ) { return "-" ; } else { return key || keyIdentifier || Keys . Unidentified ; } } export default { Keys , identifyKeyFromEvent } ;