Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifies Keyboard events to use the code property #772

Merged
merged 6 commits into from
Nov 2, 2024

Conversation

hobnob
Copy link
Member

@hobnob hobnob commented Oct 25, 2024

This is a breaking change

Fixes #766 by adding a new KeyCode enum, which is populated with the values from the code property of the KeyboardEvent. Additionally, the Key class also has a new location property, which maps to the location property of the KeyboardEvent.

All Key.*_ARROW constants are now Key.ARROW_* to bring it in line with the key codes that they relate to:

  • Key.UP_ARROW is now Key.ARROW_UP
  • Key.DOWN_ARROW is now Key.ARROW_DOWN
  • Key.LEFT_ARROW is now Key.ARROW_LEFT
  • Key.RIGHT_ARROW is now Key.ARROW_RIGHT

The KeyboardEvent itself now also supports some new additional properties:

  • isRepeat - a boolean indicating if the key is being held down
  • isCtrlKeyDown - a boolean indicating if the Ctrl key is pressed
  • isMetaKeyDown - a boolean indicating if the Meta key is pressed
  • isAltKeyDown - a boolean indicating if the Alt key is pressed
  • isShiftKeyDown - a boolean indicating if the Shift key is pressed

Additionally adds isNumeric and asNumeric methods to Key in order to fulfill #746

This is needed for the `code` property on the `KeyboardEvent`
**This is a breaking change**

Fixes #766 by adding a new `KeyCode` enum, which is populated with the
values from the `code` property of the KeyboardEvent. Additionally, the
`Key` class also has a new `location` property, which maps to the
`location` property of the KeyboardEvent.

The KeyboardEvent itself now also supports some new additional properties:
 * `isRepeat` - a boolean indicating if the key is being held down
 * `isCtrlKey` - a boolean indicating if the Ctrl key is pressed
 * `isMetaKey` - a boolean indicating if the Meta key is pressed
 * `isAltKey` - a boolean indicating if the Alt key is pressed
 * `isShiftKey` - a boolean indicating if the Shift key is pressed
@hobnob hobnob requested a review from davesmith00000 October 25, 2024 15:44
@hobnob hobnob self-assigned this Oct 25, 2024
@hobnob hobnob added enhancement New feature or request bug Something isn't working labels Oct 25, 2024
…thods to Keyboard to check for key codes in keysUp and keysDown
Also improves equality checks and adds unit tests
@hobnob hobnob linked an issue Oct 28, 2024 that may be closed by this pull request
Copy link
Member

@davesmith00000 davesmith00000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! 🎉

@davesmith00000 davesmith00000 merged commit 8563747 into main Nov 2, 2024
2 checks passed
@davesmith00000 davesmith00000 deleted the features/keyCode branch November 2, 2024 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch from keyCode to code in keyboard Add Key.isNumeric / Key.asNumber
2 participants