Utility library debug() rc_set()
Programming guideline of WinDom

keybd2ascii()

NAME

keybd2ascii - get the ascii code of a keyboard event.

PROTOTYPAGE

int keybd2ascii( int keybd, int shift);

PARAMETERS

keybd:
keyboard scancode provides by evnt_keybd() or MU_KEYBD event,

shift:
should be set to 1 if the shift key is depressed, 0 else,

retour:
tyhe ascii code associated to the event.

DESCRIPTION

keybd2ascii() identify the real ascii code of a keyboard event even the shift, control and alternate keys are depressed. When these keys are used, the ascii code in the scancode (value returned by a keyboard event) are different. Moreover, the scancode depends on the country of the keyboard. This function gets the real ascii code of the key pressed and can be used for keyboard shortcut.

EXAMPLE

     #include <windom.h>
     #include <scancode.h> /* definition of keyboard scancodes */
     
     void ex_keybd( WINDOW *win) {
     	char key =  keybd2ascii( evnt.keybd, evnt.mkstate & (K_LSHIFT|K_RSHIFT));
     	switch( key) {
     	case 'w':
     	case 'W':
     		/* key w */
     		if( evnt.mkstate & K_CTRL)
     			; /* key Control-w */
     		break;
     	/* ... */
     	default:
     		/* Some keys have no ascii code (function key, numeric pad, ...).
     		 * These keys can be identified by their scancode.
     		 */
     		switch( evnt.keybd>>8) {
     		case SC_HELP:
     			/* HELP key */
     			break;
     		/* ... */
     		}
     	}
     }