arch674
arch674

Reputation: 13

How to type from keyboard on screen in Allegro?

I want to set name of character in my Allegro game, so need to save it to string and show it on the screen. Is there better way than comparing event keycodes?

Upvotes: 1

Views: 1016

Answers (1)

rcorre
rcorre

Reputation: 7238

It sounds like you're looking for ALLEGRO_EVENT_KEY_CHAR. Listen for these events and use the keyboard.unichar field to get the character pressed.

Not that unlike ALLEGRO_EVENT_KEY_DOWN, ALLEGRO_EVENT_KEY_CHAR will fire repeatedly when the key is held (depending on the user's keyboard repeat setting). If this is undesireable, ignore events with repeat=true.

Upvotes: 1

Related Questions