I am writing a game in C++. For it, I need to detect multiple keys being pressed or held at the same time, or detect key press and key release events.
For example, if I hold both the up and right keys, I want to be able to detect this and move the game diagonally. Additionally, currently if I am holding the right key, and I press up, it no longer recognizes that right is being held. I need a way to find when the right key is actually released so it isn't interrupted like this.
I know that sdl2
can recognize multiple keys being pressed or held, but that requires creating a window, and I want this to be entirely within the terminal.
getch()
from curses/ncurses
additionally doesn't work for this.
What can I use for this? I'd like to avoid Allegro if possible.