Keyboard Input

If Pixel Vision 8 has access to the keyboard, you can capture keypresses by calling the Key() method:

Key(key, state)

The Key() method returns a boolean and you need to supply the Keycode via the Keys enum. By default, the input state is set to Buttons.Down. For example, if you just want to find the state of the A key, you can use the enum, Keys.A, or the value, 65, when calling the Key() method:

value = Key(Keys.A)

This returns true if the A key is down during the current frame. Sometimes you want to know if the key was released. You can supply a different input state when calling the Key() method. Here are the two options in the InputStateenum:

Enum

Int

InputState.Down

0

InputState.Released

1

When calling the Key() method and supplying InputState.Released, it returns true if the button was down in the previous frame but is not down in the current frame. Just like with the Buttons enum, you can use the InputStateenum or supply an int for either state.

Input String

If you are looking to just capture the last frame’s entered characters as text, for input fields, you can call InputString(). This will return a string you can use to display text that the user types. Keep in mind that characters like return, delete and escape are not included in this value.

Keys

It’s important to remember that the keyboard should only be used for tools. You can’t assume that all Pixel Vision 8 games will have access to a keyboard. The Keys enum is used to detect keyboard button presses when calling Key(). Simply pass in the enum for the key you want to test and the input state.

Enum

Value

Enum

Value

Keys.None

0

Keys.S

83

Keys.Backspace

8

Keys.T

84

Keys.Tab

9

Keys.U

85

Keys.Enter

13

Keys.V

86

Keys.Escape

27

Keys.W

87

Keys.Space

32

Keys.X

88

Keys.PageUp

33

Keys.Y

89

Keys.PageDown

34

Keys.Z

90

Keys.End

35

Keys.NumPad0

96

Keys.Home

36

Keys.NumPad1

97

Keys.Left

37

Keys.NumPad2

98

Keys.Up

38

Keys.NumPad3

99

Keys.Right

39

Keys.NumPad4

100

Keys.Down

40

Keys.NumPad5

101

Keys.Insert

45

Keys.NumPad6

102

Keys.Delete

46

Keys.NumPad7

103

Keys.Alpha0

48

Keys.NumPad8

104

Keys.Alpha1

49

Keys.NumPad9

105

Keys.Alpha2

50

Keys.Multiply

106

Keys.Alpha3

51

Keys.Add

107

Keys.Alpha4

52

Keys.Separator

108

Keys.Alpha5

53

Keys.Subtract

109

Keys.Alpha6

54

Keys.Decimal

110

Keys.Alpha7

55

Keys.Divide

111

Keys.Alpha8

56

Keys.LeftShift

160

Keys.Alpha9

57

Keys.RightShift

161

Keys.A

65

Keys.LeftControl

162

Keys.B

66

Keys.RightControl

163

Keys.C

67

Keys.LeftAlt

164

Keys.D

68

Keys.RightAlt

165

Keys.E

69

Keys.Semicolon

186

Keys.F

70

Keys.Plus

187

Keys.G

71

Keys.Comma

188

Keys.H

72

Keys.Minus

189

Keys.I

73

Keys.Period

190

Keys.J

74

Keys.Question

191

Keys.K

75

Keys.Tilde

192

Keys.L

76

Keys.OpenBrackets

219

Keys.M

77

Keys.Pipe

220

Keys.N

78

Keys.CloseBrackets

221

Keys.O

79

Keys.Quotes

222

Keys.P

80

Keys.Backslash

226

Keys.Q

81

Keys.OemClear

254

Keys.R

82