Skip to content

Multiple keyboard keys / joystick repeat event? #333

Closed Answered by falkoschindler
FlorentLM asked this question in Q&A
Discussion options

You must be logged in to vote

Both elements fire events only when something changes. Key events are closely coupled to the corresponding JavaScript events: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent. They don't tell you what keys are currently pressed, but which key is changing its state, either down or up. If you need to know all currently pressed keys, you need to keep track of them yourself, unfortunately. The joystick behaves similarly: It only fires on change. Otherwise it would need to constantly send events at enormous (actually infinite) frequency.

When implementing a game, you usually have some game loop that checks inputs and updates the output in regular intervals. You could, e.g., use a u…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@FlorentLM
Comment options

Answer selected by falkoschindler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #319 on February 01, 2023 07:19.