Partager via


INKEY( ) Function

Returns a number corresponding to the first mouse click or key press in the type-ahead buffer.

INKEY([nSeconds] [, cHideCursor])

Return Values

Numeric

Parameters

  • nSeconds
    Specifies how many seconds INKEY( ) waits for a keystroke. If nSeconds isn't included, INKEY( ) immediately returns a value for a keystroke. INKEY( ) waits indefinitely for a keystroke if nSeconds is 0.

  • cHideCursor
    Shows or hides the cursor, or checks for a mouse click. To show the cursor, include S in cHideCursor. To hide the cursor, include H in cHideCursor. If both S and H are included in cHideCursor, the last character in cHideCursor takes precedence.

    By default, INKEY( ) doesn't detect a mouse click. To check for a mouse click, include M in cHideCursor. If M is included in cHideCursor, INKEY( ) returns the value 151 for a single mouse click. Refer to the second example in the following table to see how you can check for a double click.

    To check for a mouse click and show the cursor, include both M and S. To check for a mouse click and hide the cursor, include H and M.

    When a keyboard macro is assigned to a key or key combination, you can include E in cHideCursor to expand the keyboard macro. When E is included, INKEY( ) returns a value corresponding to the first keystroke assigned to the keyboard macro. You can return successive values for each keystroke in a macro by repeatedly executing INKEY( ) with E included. If you omit E, INKEY( ) returns the value for the key or key combination that triggers the keyboard macro.

    Any characters other than H, M, S, and E in cHideCursor are ignored.

    The following table lists INKEY( ) function return values for keys alone and in combination with the SHIFT, CTRL, and ALT keys. A dash (–) indicates that the key combination returns no value.

    Key Alone SHIFT CTRL ALT
    F1 28 84 94 104
    F2 –1 85 95 105
    F3 –2 86 96 106
    F4 –3 87 97 107
    F5 –4 88 98 108
    F6 –5 89 99 109
    F7 –6 90 100 110
    F8 –7 91 101 111
    F9 –8 92 102 112
    F10 –9 93 103 113
    F11 133 135 137 139
    F12 134 136 138 140
    1 49 33 120
    2 50 64 121
    3 51 35 122
    4 52 36 123
    5 53 37 124
    6 54 94 125
    7 55 38 126
    8 56 42 127
    9 57 40 128
    0 48 41 19
    a 97 65 1 30
    b 98 66 2 48
    c 99 67 3 46
    d 100 68 4 32
    e 101 69 5 18
    f 102 70 6 33
    g 103 71 7 34
    h 104 72 127 35
    I 105 73 9 23
    j 106 74 10 36
    k 107 75 11 37
    l 108 76 12 38
    m 109 77 13 50
    n 110 78 14 49
    o 111 79 15 24
    p 112 80 16 25
    q 113 81 17 16
    r 114 82 18 19
    s 115 83 19 31
    t 116 84 20 20
    u 117 85 21 22
    v 118 86 22 47
    w 119 87 23 17
    x 120 88 24 45
    y 121 89 25 21
    z 122 90 26 44
    INS 22 22 146 162
    HOME 1 55 29 151
    DEL 7 7 147 163
    END 6 49 23 159
    PAGE UP 18 57 31 153
    PAGE DOWN 3 51 30 161
    UP ARROW 5 56 141 152
    DOWN ARROW 24 50 145 160
    RIGHT ARROW 4 54 2 157
    LEFT ARROW 19 52 26 155
    ESC 27 –/27 –*/27 –*/1
    ENTER 13 13 10 –/166
    BACKSPACE 127 127 127 14
    TAB 9 15 148/* *
    SPACEBAR 32 32 32/– 57

    * Keystroke reserved by Windows.

Remarks

INKEY( ) returns 0 if a key isn't pressed. If there are several keys in the type-ahead buffer, INKEY( ) returns the value of the first key entered in the buffer.

See Also

_DBLCLICK | KEYBOARD | KeyPress Event | LASTKEY( ) | ON KEY | READKEY( ) | SET TYPEAHEAD