I would like to write a function that replaces the old keypressed() in Allegro 4.4 but this function must be non-blocking (because called in the game loop). I have found this link :https://www.allegro.cc/forums/thread/610536

The "proper" way in Allegro 5 is to check for keyboard events in your event loop. If you just need to wait for an arbitrary keypress, you can do something like the code I posted in the thread to linked to.

If you are already in the event loop, waiting for any key is just this: