readkey(3)

NAME
readkey

SYNOPSIS
#include <allegro.h>

int readkey();

DESCRIPTION
Returns the next character from the keyboard buffer, in ASCII format. If the buffer is empty, it waits until a key is pressed. The low byte of the return value contains the ASCII code of the key, and the high byte the scancode. The scancode remains the same whatever the state of the shift, ctrl and alt keys, while the ASCII code is affected by shift and ctrl in the normal way (shift changes case, ctrl+letter gives the position of that letter in the alphabet, eg. ctrl+A = 1, ctrl+B = 2, etc). Pressing alt+key returns only the scancode, with a zero ASCII code in the low byte. For example:
   if ((readkey() & 0xff) == 'd')         // by ASCII code
      printf("You pressed 'd'\n");

   if ((readkey() >> 8) == KEY_SPACE)     // by scancode
      printf("You pressed Space\n");

   if ((readkey() & 0xff) == 3)           // ctrl+letter
      printf("You pressed Control+C\n");

   if (readkey() == (KEY_X << 8))         // alt+letter
      printf("You pressed Alt+X\n");

This function cannot return character values greater than 255. If you need to read Unicode input, use ureadkey() instead.

SEE ALSO
install_keyboard(3), ureadkey(3), keypressed(3), clear_keybuf(3), simulate_keypress(3)