I am trying to figure out how can I make Scala Swing react to multiple key events that are happening at the same time. I know how Swing can detect one key that is pressed, but for example how can it detect if two keys are pressed at the same time? Note: No Java experience
I know that the first event does not work, but I try to represent what I am trying accomplish with it:
reactions += {
//case KeyPressed(_, Key.Space && Key.Up, _, _)
//label.text = "Space and Up are down"
case KeyPressed(_, Key.Space, _, _) =>
label.text = "Space is down"
case KeyPressed(_, Key.Up, _, _) =>
label.text = "Up is down"
}
Any ideas that might help? Or straight up answers how to do it?
Make a buffer that holds all the keys that are pressed
When key is pressed add the key to the buffer and check if the buffer contains some wanted key values
Clear the buffer when button released