Gets the first keystroke waiting in the keyboard typeahead buffer. Can also be used to wait for a keystroke and return its value.

Syntax

INKEY([<seconds expN>] [, <mouse expC>])

<seconds expN>

The number of seconds INKEY( ) waits for a keystroke. Fractional times are allowed. If <expN> is zero, INKEY( ) waits indefinitely for a keystroke. If <expN> is less than zero, the parameter is ignored.

<mouse expC>

Determines whether INKEY( ) returns a value when you click the mouse. If <expC> is "M" or "m", INKEY( ) returns –100. If <expC> is not "M" or "m", INKEY( ) ignores a mouse click and waits for a keystroke.

Description

The keyboard typeahead buffer stores keystrokes the user enters while dBASE Plus is busy. A very fast typist may also fill the keyboard typeahead buffer—dBASE Plus is busy trying to keep up. These keystrokes are normally handled automatically; for example, characters are typed into entryfields and menu choices are made. Use INKEY( ) to handle the keystrokes yourself.

INKEY( ) returns the decimal value associated with the first key or key combination held in the keyboard typeahead buffer and removes that keystroke from the buffer. If the typeahead buffer is empty, INKEY( ) returns the value of zero.

Key pressed

Return value

Shift+key
return value

Ctrl+Key
return value

Alt+key*
return value

0

48

Depends on keyboard

–404

–452 

1

49

Depends on keyboard

–404

–451 

2

50

Depends on keyboard

–404

–450 

3

51

Depends on keyboard

–404

–449 

4

52

Depends on keyboard

–404

–448 

5

53

Depends on keyboard

–447 

6

54

Depends on keyboard

–30

–446 

7

55

Depends on keyboard

–404

–445 

8

56

Depends on keyboard

–404

–444 

9

57

Depends on keyboard

–404

–443 

a

97

65

1

–435 

b

98

66

2

–434 

c

99

67

3

–433 

d

100

68

4

–432 

e

101

69

5

–431 

f

102

70

6

–430 

g

103

71

7

–429 

h

104

72

8

–428 

i

105

73

9

–427 

j

106

74

10

–426 

k

107

75

11

–425 

l

108

76

12

–424 

m

109

77

13

–423 

n

110

78

14

–422 

o

111

79

15

–421 

p

112

80

16

–420 

q

113

81

17

–419 

r

114

82

18

–418 

s

115

83

19

–417 

t

116

84

20

–416 

u

117

85

21

–415 

v

118

86

22

–414 

w

119

87

23

–413 

x

120

88

24

–412 

y

121

89

25

–411 

z

122

90

26

–410 

F1 (Ctrl+\)

28

–20

–10

–30 

F2

–1

–21

–11

–31 

F3

–2

–22

–12

–32 

F4

–3

–23

–13

–33 

F5

–4

–24

–14

–34 

F6

–5

–25

–15

–35 

F7

–6

–26

–16

–36 

F8

–7

–27

–17

–37 

F9

–8

–28

–18

–38 

F10

–9

–29

–19

–39 

F11

–544

–546

–548

–550

F12

–545

–547

–549

–551

Left Arrow

19

–500

1

Right Arrow

4

–501

6

Up Arrow

5

5

5

Down Arrow

24

24

24

Home (Ctrl+])

26

26

29

End

2

2

23

Tab

9

–400

0

Enter

13

0

–402

Esc (Ctrl+[)

27

27

-

-

Ins

22

0

0

Del

7

–502

7

Backspace

127

127

–401

–403

PgUp

18

18

31

PgDn

3

3

30

 

Note

The Alt+key value returned for all character keys, except lower-case letters a through z, is the character value minus 500. For lower-case letters, the Alt+key values are the same as those for upper-case letters.

Because of the event-driven nature of dBASE Plus, INKEY( ) is rarely used. When it is used, it’s in one of three ways:

When keystrokes are expected to be buffered, INKEY( ) is used to get those keystrokes.

In a loop that’s busy doing something, INKEY( ) is used to see if a key has been pressed, and if so to take an action.

INKEY( ) can be used to wait for a keystroke, and then take an action.

In any of these cases, because dBASE Plus is busy executing your INKEY( ) code, it will not respond to keystrokes and mouse clicks as it normally would.

To check if there is a key waiting in the buffer without removing it, or to determine a value in the buffer in a position other than the first position, use NEXTKEY( ).