Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Keys get stuck when switching windows with ALT+TAB

This thread is locked; no one can reply to it. rss feed Print
Keys get stuck when switching windows with ALT+TAB
promitheas
Member #23,510
September 2022

I am working on a game, and I noticed that when using al_key_down, if I switch windows with alt+tab, allegro will think that I am holding alt down, until I press and release it again. Anyone know anything I can do to fix this?

torhu
Member #2,727
September 2002
avatar

What version of Allegro? IIRC, this was fixed many years ago.

promitheas
Member #23,510
September 2022

ALLEGRO_VERSION_STR is 5.2.7, so that's probably the version

torhu
Member #2,727
September 2002
avatar

The headers can have a different version from the binaries. You can check the real version by printing what al_get_allegro_version returns. Did you build the binaries yourself?

APPEND:
Maybe I'm mistaken, sorry. You can try calling al_clear_keyboard_state when you get the ALLEGRO_EVENT_DISPLAY_SWITCH_OUT event, that should fix it.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

promitheas
Member #23,510
September 2022

Thanks, al_clear_keyboard_state() fixed it.
To use it I had to define ALLEGRO_UNSTABLE. Will it be wrong to only define ALLEGRO_UNSTABLE when I want to use functions that require it, or do I have to always define it before including anything from ALLEGRO?

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: