ctcuff / stargazers

Final team project for CAP 4720
https://ctcuff.github.io/stargazers/
3 stars 2 forks source link

Input class uses event.key instead of event.code #57

Open TheIceCreamBear opened 2 years ago

TheIceCreamBear commented 2 years ago

https://github.com/ctcuff/stargazers/blob/master/src/input.js#L45

event.key returns the key that was pressed including keyboard accelerators. This means that if the user presses the 'a' key with shift also pressed, it will be recognized as 'A' and not 'a'. This can have the side effect of breaking the UFO interaction.

Further, if the user presses the 'a' key, then presses shift (causing the event to trigger 'A' and not 'a'), then lets go of the 'a' key, the ship will still move to the left as the key up event was not fired for the 'a' key.