joelnet / konami-code-react-component

Konami Code React Component
3 stars 1 forks source link

fix(event.key): use event.key instead of event.code #2

Open thib3113 opened 1 year ago

thib3113 commented 1 year ago

event.code return the physical code of the keyboard, so it can change depending on you keyboard layout .

Using event.key will provide the real key pressed .

to illustrate, on an azerty keyboard, pressing A :

{ 
    "altKey": false,
    "charCode": 0,
    "code": "KeyQ", //the physical key
    "ctrlKey": false,
    "key": "a", //the logical key (depending of the layout)
    "keyCode": 65,
    "which": 65 
}

Fix #1