KeyFromChar(char, fCtrl, fShift, fAlt)

Returns a key value, given a character and modifier key states. A key value is a numeric keyboard value that is returned by GetKey. You can use CharFromKey to convert a key value into a character.

Inputs:

char - the character part of the keystroke. It is not case sensitive.

fCtrl - non-zero if the CTRL key is included.  

fShift - non-zero if the Shift key is included.  

fAlt - non-zero if the ALT key is included.

The char parameter can have some special values:

Table 5.6: "char' Parameter Values and Their Meanings

Char Value

Meaning

a-z

Simple alpha characters

Fx

Function Key number x; e.g. F10

Nx

Numeric keypad character x; e.g. N+ for "+" key

Up, Down, Left, Right

Arrow keys

Page Up, Page Down

Insert, Delete

Home, End,

Tab, Enter

Other special keys

 

Examples of Key Assignments:

// assign Ctrl+C to Page Down command:

key = KeyFromChar("c", 1, 0, 0);  // Ctrl+C

AssignKeyToCmd(key, "Page Down");

 

// assign F9 to Close Project command:

key = KeyFromChar("F9", 0, 0, 1);  // Alt+F9

AssignKeyToCmd(key, "Close Project");

 

Examples of input functions:

// input a keypress and decode it

key = GetKey()

if (IsFuncKey(key))

   Msg cat("Function key = ", FuncFromKey(key))

if (IsAltKeyDown(key))

   Msg "Alt key down"

if (IsCtrlKeyDown(key))

   Msg "Ctrl key down"

ch = CharFromKey(key)

if (Ascii(ch) == 13)

   Msg "You pressed Enter!"

else if (toupper(ch) == 'S')

   Search_Files

...