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?
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
.