reactjs / react-autocomplete

WAI-ARIA compliant React autocomplete (combobox) component
MIT License
2.17k stars 532 forks source link

How to access keyCode from input value #263

Closed charlieroth closed 7 years ago

charlieroth commented 7 years ago

This isn't really an issue with react-autocomplete itself but I was wondering how I can access the keyCode value from the input element that is generated by the AutoComplete component?

CMTegner commented 7 years ago

Hi Charles! First you need to figure out which event you want to listen to to intercept the keyboard event. You're probably after keyDown, in which case you can use props.inputProps.onKeyDown. All valid event handlers found in props.inputProps are attached to the <input> element generated by Autocomplete, and work just like you would expect (i.e. they receive the event object as their sole argument).

Hope this was what you were after!