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

For keyboard use KeyboardEvent.code instead KeyboardEvent.key #16

Open
justgook opened this issue Jan 4, 2020 · 0 comments
Open

For keyboard use KeyboardEvent.code instead KeyboardEvent.key #16

justgook opened this issue Jan 4, 2020 · 0 comments

Comments

@justgook
Copy link

justgook commented Jan 4, 2020

KeyboardEvent.key is good for somewhere where you need to type, and a is not same as A, but for something interactive - as games / visual interactive applications - better use KeyboardEvent.code - as for games - more important is position of button instead of it typing value.
Other critical part is when you would like (and most of gamers prefer) use WASD (ZQSD on AZERTY) fro player control, and that not matters what keyboard they use, other part if i would like use Shift key in combination with all that stuff, that would ruin all logic what im doing as it will require much more validations..

total off topic but you can save few renders with improving keyDown event:

            (D.field "key" D.string
                |> D.andThen
                    (\k ->
                        if Set.member k computer.keyboard.keys then
                            D.fail ""

                        else
                            D.succeed (KeyChanged True k)
                    )
            )```
that will not trigger non-renderable frame few times while player holds key (as it is sends keydown event few times in sec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant