ts-key-namespace
A TypeScript namespace declaration for KeyboardEvent.key strings, just in case you prefer namespaces to enums. Largely based on ts-key-enum
by Nathan Friend. ts-key-enum
also probably works better.
Install
npm install ts-key-namespace --save
Import
import Key from "ts-key-namespace";
Example
onKeyDown={(ev: KeyboardEvent<HTMLInputElement>)=>{
if(ev.key === Key.Enter) {
console.log("Stuff");
}
}}