opendarwin man page for readkey

Query: readkey

OS: opendarwin

Section: 3alleg4

Links: opendarwin man pages   all man pages

Forums: unix linux community   forum categories

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

readkey(3alleg4)						  Allegro manual						  readkey(3alleg4)

NAME
readkey - Returns the next character from the keyboard buffer. Allegro game programming library.
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. You can see if there are queued keypresses with keypressed(). 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 scan- code, with a zero ASCII code in the low byte. For example: int val; ... val = readkey(); if ((val & 0xff) == 'd') /* by ASCII code */ allegro_message("You pressed 'd' "); if ((val >> 8) == KEY_SPACE) /* by scancode */ allegro_message("You pressed Space "); if ((val & 0xff) == 3) /* ctrl+letter */ allegro_message("You pressed Control+C "); if (val == (KEY_X << 8)) /* alt+letter */ allegro_message("You pressed Alt+X "); This function cannot return character values greater than 255. If you need to read Unicode input, use ureadkey() instead.
SEE ALSO
install_keyboard(3alleg4), ureadkey(3alleg4), keypressed(3alleg4), clear_keybuf(3alleg4), simulate_keypress(3alleg4) Allegro version 4.4.2 readkey(3alleg4)
Related Man Pages
readkey(3alleg4) - mojave
readkey(3alleg4) - osx
readkey(3alleg4) - php
readkey(3alleg4) - plan9
readkey(3alleg4) - x11r4
Similar Topics in the Unix Linux Community
How to issue ctrl+D and enter key
Trouble freeing memory after ctrl+D
Passing ctrl + c in shell scripting
Conditional for every letter in alphabet
Text formatting