whscullin / apple2js

An Apple II emulator originally written in Javascript, now being converted to TypeScript
http://www.scullinsteel.com/apple2/
MIT License
438 stars 57 forks source link

Refactor key handling to use `event.key` #152

Closed iflan closed 2 years ago

iflan commented 2 years ago

Before, keyboard input used key codes to map events to Apple II keys. This worked reasonably well, but event.keyCode was deprecated and slated to be removed.

The refactored code now uses event.key which returns the localized, keyboard-mapped key that the user pressed, which may be a letter or a "symbolic" key. This is then transformed into an Apple II key.

One side effect of the refactoring is that the keys now light up as you type and that combinations of mouse clicks on modifiers and plain keys will take the modifiers into account.