Open George3d6 opened 1 month ago
onKeyPress
is a TextInput only prop / event which I suppose bubbled up without us realizing.. I wouldn't rely on that. We inherit that prop from React Native on mobile, and it doesn't really fit into the desktop keyboard API.
For global keyboard listening, since React Native is mostly only Root view and down, I think you still have to rely on implementing that natively with something like https://github.com/sindresorhus/KeyboardShortcuts unfortunately.
Reading through https://github.com/microsoft/react-native-macos/issues/966 and https://github.com/microsoft/react-native-macos/issues/823 It seemed that the recommended way to get global keyboard listeners was using
onKeyDown
on a top-levelView
This seems not to work however I found:
Works just fine (even though the type of
View
doesn't specify it ... however it only works after I e.g. click a specificTextInput
(even if I move it out of focus later).Is there an updated workaround to getting global keyboard listening to work (thus allowing things like hotkeys/shortcuts) ?