joelnet / konami-code-react-component

Konami Code React Component
3 stars 1 forks source link

Using event.Code can cause problems on other keyboards #1

Open thib3113 opened 1 year ago

thib3113 commented 1 year ago

Hello, about this line : https://github.com/joelnet/konami-code-react-component/blob/f72d2480b53226e71740a8f532527f46d1c7bbd5/src/SecretCode/useInputEvent.js#L7

the problem here, will be that will not work on some keyboard . An example with an azerty Keyboard : If I press "a" :

{ 
    "altKey": false,
    "charCode": 0,
    "code": "KeyQ",
    "ctrlKey": false,
    "key": "a",
    "keyCode": 65,
    "which": 65 
}

event.code will pass the code of the physical key, and not the real key pressed

joelnet commented 1 year ago

Ahh that is good to know. I assumed all keypresses were handled with a code. Do you want to submit a pull request?

thib3113 commented 1 year ago

Done, but maybe you will need to update your blog post too :) .