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

feat: getKeysPressed() getKeysDown() functions #551

Open
candycarmel opened this issue Dec 1, 2024 · 2 comments
Open

feat: getKeysPressed() getKeysDown() functions #551

candycarmel opened this issue Dec 1, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request input Related to Input System
Milestone

Comments

@candycarmel
Copy link

currently, there is no way to "easily" get all keys pressed / down

two functions, getKeysPressed(), and getKeysDown()

they should return arrays of keys pressed, and keys down that frame

@candycarmel candycarmel added the enhancement New feature or request label Dec 1, 2024
@lajbel lajbel moved this from TODO to WIP in KAPLAY.js Features Dec 18, 2024
@lajbel lajbel self-assigned this Jan 20, 2025
@lajbel lajbel added this to the 4000 milestone Jan 20, 2025
@lajbel lajbel added the input Related to Input System label Jan 20, 2025
@lajbel
Copy link
Collaborator

lajbel commented Jan 23, 2025

getKeysPressed or getKeysReleased really makes sense? I mean would you use it? At that point wouldn't be better a getKeysState().pressed.has(key)?

@imaginarny
Copy link
Contributor

So for example this is keysDown:

const keysDown = new Set()
onKeyDown(k => keysDown.add(k))
onKeyRelease(k => keysDown.delete(k))

onUpdate(() => keysDown.size && debug.log(...keysDown.keys()))

But keysPressed would be much harder to do and I'm not sure how that would be usable. As those are basically keys that were down on "previous frame" or released, so idk how and when you would use it to match the timing it was pressed, otherwise it would appear empty.

Maybe I understand it wrong. Got any use case or specific reason? Would't be keysDown sufficient as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request input Related to Input System
Projects
Status: WIP
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants