Low-Level Keyboard Handler

Fastgraph includes a low-level keyboard handler that is especially well suited to game development because it increases keyboard responsiveness in high-speed action games. Unlike Fastgraph for DOS, you do not need to explicitly enable the low-level keyboard handler in Fastgraph for Windows because it is always available.

The fg_kbtest() function checks if certain keys are currently pressed or released. You specify the keys through scan codes. If the corresponding key is pressed, fg_kbtest() returns 1; if it is released, it returns zero. The fg_kbtest() function can test if any key is pressed if you pass it the value 0 instead of a specific scan code. The following table lists the scan codes corresponding to the keys on a standard PC keyboard.

key

code

key

code

key

code

key

code

Esc

1

I

23

X

45

F9

67

1

2

O

24

C

46

F10

68

2

3

P

25

V

47

NumLock

69

3

4

[

26

B

48

ScrLock

70

4

5

]

27

N

49

Home

71

5

6

Enter

28

M

50

(

72

6

7

Ctrl

29

,

51

PgUp

73

7

8

A

30

.

52

KP-

74

8

9

S

31

/

53

(

75

9

10

D

32

R shift

54

KP5

76

0

11

F

33

KP*

55

®

77

-

12

G

34

Alt

56

KP+

78

=

13

H

35

Space

57

End

79

BS

14

J

36

CapsLock

58

(

80

Tab

15

K

37

F1

59

PgDn

81

Q

16

L

38

F2

60

Ins

82

W

17

;

39

F3

61

Del

83

E

18

'

40

F4

62

(unused)

84

R

19

`

41

F5

63

(unused)

85

T

20

L shift

42

F6

64

(unused)

86

Y

21

\

43

F7

65

F11

87

U

22

Z

44

F8

66

F12

88

There are actually more scan codes defined for PC keyboards than listed in this table. Such scan codes are generated when a key is pressed as a combination of one or more keys, such as when the shift and slash keys are pressed together to produce a question mark (?) character. The low-level keyboard handler is designed to report the pressing or releasing of keys themselves, as opposed to reporting the actual characters so produced. It is thus not possible for the keyboard handler to report the scan code for a multi-key character. If needed, such characters can be identified by the scan codes generated for each key in the sequence. For example, a question mark character would be reported as a forward slash (scan code 53) generated while pressing the left shift (42) or right shift (54) keys.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.