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

Handle keyboard input better #19

Open
linusrachlis opened this issue Oct 1, 2023 · 0 comments
Open

Handle keyboard input better #19

linusrachlis opened this issue Oct 1, 2023 · 0 comments
Labels
enhancement New feature or request ux

Comments

@linusrachlis
Copy link
Owner

Keyboard input causes weirdness like making the mouse pointer flicker, or highlighting text on the page when using Shift + arrows.

  • Have a global mode switch so either (1) the game is fully capturing keyboard (and keyboard event handlers use preventDefault() and stopPropagation()), or (2) the game is not receiving keyboard input at all. A button or checkbox in the UI controls this. Or maybe you can just click on the Canvas too.
  • Keyboard users can hit ESC to stop capturing?
  • The page gives a visual indicator for the mode.
  • Also, use hotkeys for mode toggles. Maybe numbers? Will it be okay to limit myself to 10 modes? ... 😁
@linusrachlis linusrachlis added enhancement New feature or request ux labels Oct 1, 2023
linusrachlis added a commit that referenced this issue Oct 3, 2023
This addresses issue #19. However, main.ts is getting quite unweildy
with spaghetti state management. In addition, there is a conceptual
issue becoming clear between game-rendered input prompts and DOM-level
input prompts. E.g. in the game-over state, the game renders the message
"Space to restart," but now that only works if the game is not "paused,"
aka input is being captured. As another example, the hotkeys identified
by the game-mode checkbox labels only work when input is captured, but
that's not clear from looking at them.

The plan for the state management issue is to rewrite the UI in React,
which will be the next bit of work.

I'm not sure OTTOMH what to do about the conceptual issue, but I think
clarifying state management may help in thinking it through.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ux
Projects
None yet
Development

No branches or pull requests

1 participant