You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One of the core fundamentals of this library is going to be the ability for developers to pick up on key presses and do something with that action. I haven't completely determined how I'd like this to work though!
Here are the different things I want to be able to track:
Key(s) Down
Key(s) Up
Key(s) Hold (for a specified amount of time)
Each of these should have the ability to specify either one or multiple keys to listen for. For example I could say when key 1 is pressed down do something, or when both keys 1, 3, and 5 are all pressed at the same time do something else.
Key hold is an interesting one and I don't believe should be exclusive from other events (in that it will still call key up after the specified time) and should be called once as soon as the time has been reached.
The text was updated successfully, but these errors were encountered:
"Listener" (Similar to NotificationCenter) where the client would add/remove observers from the main/key classes with an event type (from an enum). When data comes in we simply loop through all of the active listener, filter on those which are applicable, and send out the relevant information to the selector/block provided.
Delegate (Fairly common) where the client would specify itself as the target and would have three functions for keyDown, keyUp and keyHold (time is passed through, and is sent every second until released) this removes the need for a client to add multiple listeners.
letkeyOne=...letkeyTwo=...leteventObserver= keyOne.onKeyDown{
// Key down
}
keyOne.onKeyUp{
// Key up
}
keyOne.onKeyHold(for:1){
// Key held for 1 second
}[keyOne, keyTwo].onKeysDown{
// Both keys are down
}[keyOne, keyTwo].onKeysHold(for:1){
// Both keys have been held down for 1 second
}
eventObserver.clear() // Clears single listener
keyOne.clearListeners() // Clears all listeners exclusively on a single key (not multi key ones)
streamDeck.clearAllListeners() // Clears all listeners
onKeysUp for multiple keys I believe is going to be a bit more complicated but could fit within the same idea. (Would need to track that both keys have been put down first, and then both released)
All functions will return a token which can be used to remove it at a later date to stop it tracking. This can be ignored though.
One of the core fundamentals of this library is going to be the ability for developers to pick up on key presses and do something with that action. I haven't completely determined how I'd like this to work though!
Here are the different things I want to be able to track:
Each of these should have the ability to specify either one or multiple keys to listen for. For example I could say when key 1 is pressed down do something, or when both keys 1, 3, and 5 are all pressed at the same time do something else.
Key hold is an interesting one and I don't believe should be exclusive from other events (in that it will still call key up after the specified time) and should be called once as soon as the time has been reached.
The text was updated successfully, but these errors were encountered: