Typescript/React what’s the correct type of the parameter for onKeyPress?
This seems to work: handleKeywordKeyPress = (e: React.KeyboardEvent<FormControl>) =>{ if( e.key == ‘Enter’ ){ if( this.isFormValid() ){ this.handleCreateClicked(); } } }; The key(Ha ha) here, for me, was to specify React.KeyboardEvent, rather than KeyboardEvent. Trolling around the React code, I was seeing definitions like: type KeyboardEventHandler<T> = EventHandler<KeyboardEvent<T>>; But didn’t realise that when I was … Read more