Seppo420
Seppo420

Reputation: 2249

How to detect ⌘ + something key combos with React

Evt is a SyntheticEvent here:

handleEnterPress(evt){

        if(evt.ctrlKey){
            doSomething();
        }
        //..

}

Apparently ⌘+enter does not set evt.ctrlKey here? How do I catch those events then?

Upvotes: 0

Views: 218

Answers (1)

Thomas Hennes
Thomas Hennes

Reputation: 9979

Check out the reference for KeyboardEvent on MDN

event.metaKey is probably the event you're after. Check out the example at the bottom of the page linked above.

Upvotes: 1

Related Questions