Small keyboard and modifier related issue/bug


I am using Allegro 5.0.8 (on Windows 8) and have just noticed a small issue with keyboard events and modifiers. Basically, if you try to re-create your display while pressing a key with a modifier - sometimes the modifier will "stick" in that any further key pressed also send the same modifier (as a flag in event.modifiers).

As an example - in my game I use Alt+Enter to switch to the fullscreen. I am using the real fullscreen mode where I need to re-create the display. If I keep pressing Alt-Enter a couple of times - the "Alt" modifier sticks for any further keyboard events (so for example pressing just A after the bug - will actually trigger Alt+A).

As a workaround I found I can al_uninstall_keyboard() before re-creating the display and then al_install_keyboard() and re-registering keyboard event source. This fixes the problem, but I am not sure if this is intended behavior or a small bug?

André Silva

This problem happens occasionally, not just in Allegro games. I remember playing some games where I want to Alt+Tab, and when I come back, the game thinks I'm holding Alt. As a player, it can be fixed by pressing the "stuck" key again, but as a programmer, particularly in this case, with Allegro... I don't know of anything you can do.

Thread #611722. Printed from