Skip to content

"Global" keyboard listening #2220

@George3d6

Description

@George3d6

Reading through #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-level View

This seems not to work however I found:

onKeyPress={(e)=> {
        console.log(e.nativeEvent.key)
    }}

Works just fine (even though the type of View doesn't specify it ... however it only works after I e.g. click a specific TextInput (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) ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions