I am using the react-select vserion 2 component. I want to be able to trigger the OnKeyDown event when someone presses the backspace key.
Does anyone know how to do this?
I am using the react-select vserion 2 component. I want to be able to trigger the OnKeyDown event when someone presses the backspace key.
Does anyone know how to do this?
react-select
provides a prop onKeyDown
which you can use as the following example:
const onKeyDown = e => {
// catch the code of the key pressed
if (e.keyCode === 8) {
// do your stuff
}
};
In this function you can catch the keyCode
of the key pressed.
Here a live example.