2

I am trying to make a text box in allegro and need a way of getting the ascii keycodes from the key presses. The ev.type == ALLEGRO_EVENT_KEY_DOWN does not always work. I have tried getting the event to work faster but it is still slow.

If there is a way I could make this into a function that could give the Ascii char of what ever key is pressed, it would be great. (I have been looking but I cant find something easy and fast for the source code that I am using)

Main menu
  • 33
  • 4

1 Answers1

4

Perhaps you are looking for an ALLEGRO_EVENT_KEY_CHAR event type. These events are generated every time a character is typed on the keyboard, or auto-repeated because the key was held down long enough. In other words, while ALLEGRO_EVENT_KEY_UP/DOWN events correspond to the keyboard state, ALLEGRO_EVENT_KEY_CHAR events correspond to the character input buffer state.

Gassa
  • 8,546
  • 3
  • 29
  • 49
  • I am using that and it is too fast. How could I fix this? Do you need code for this. – Main menu Mar 08 '19 at 22:13
  • @Mainmenu Repeat speed depends on BIOS or OS settings, or maybe otherwise. – Gassa Mar 09 '19 at 11:43
  • @Mainmenu In any case, please formulate your question more precisely. Currently "it's too slow" in the question and "it's too fast" in the comment above contradict each other. Hard to answer a contradictory question. – Gassa Mar 09 '19 at 11:44
  • In my program it does not get every key event. This is maybe because I am using recursive functions that call a main keyboard function many times per iteration of the main loop. Sorry for not giving the answer the first time. – Main menu Mar 14 '19 at 02:31