Skip to content Skip to sidebar Skip to footer

How Do I Set Up An 'onkeypress' Handler On A In React?

I am familiar with React and its event system, but I can't seem to get the onKeyPress event to fire on a element. In fact, I can't get it to fire on a
e

Solution 1:

Just assign tabIndex to the element for getting the focus.

<canvas tabIndex="0" onKeyPress={ () =>console.log( 'fired' ) } />

Solution 2:

canvas.addEventListener('keydown', function(event) {
    alert('keydown');
        }, false);

Check if you can fire the above event :)

Post a Comment for "How Do I Set Up An 'onkeypress' Handler On A In React?"