react-native-keyevent icon indicating copy to clipboard operation
react-native-keyevent copied to clipboard

How to use preventDefault() ?

Open webdevabhi opened this issue 3 years ago • 3 comments

Hi i have a need to read the pressed key and prevent from actual key press.

As KeyEvent is only returning me {"action": 1, "keyCode": 30, "pressedKey": "B"} How to access the event object to preventDefault() ?

webdevabhi avatar Jan 19 '23 07:01 webdevabhi

Once your app intercepts a keyEvent the default behavior for that keyEvent is prevented by default.

For what purpose would you want to preventDefault()?

thegreatzeus avatar Jan 30 '24 12:01 thegreatzeus

I want to prevent behaviour after read my key i see react native click inside my app. I want to prevent this behaviour.

sergeushenecz avatar Mar 15 '24 15:03 sergeushenecz

I want to prevent behaviour after read my key i see react native click inside my app. I want to prevent this behaviour.

I can confirm this is a bug where the first keyEvent is not caught and is handled by the OS with default behavior. All subsequent keyEvents are caught and handled by react-native-keyevent.

thegreatzeus avatar Mar 19 '24 12:03 thegreatzeus