ayrton / react-key-handler

React component to handle keyboard events :key:
http://ayrton.be/react-key-handler
388 stars 29 forks source link

Prevent default (Browser arrow scrolling) #143

Closed xAlstrat closed 6 years ago

xAlstrat commented 6 years ago

I would like to use arrow keys for moving elements. This works great. But when I press 'up' and 'down' keys the browser scroll is also activated.

How can I prevent this default behavior? I'm working with React components:

<KeyHandler keyEventName={KEYPRESS} keyValue="ArrowLeft" onKeyHandle={this.moveEventLeft} />

The function doesn't seem to have an event parameter.

Thanks !

xAlstrat commented 6 years ago

I'm blind.

The only parameter is an event. Just had to do e.preventDefault().