EventToString
EventToString(keyCode)
Returns the name of a keycode.
Return Type: string
keyCode:
Type:
integer
Note:
There is a list of the keycodes at the bottom of this
page.
Sample
Code
# import GameKeys module
import GameKeys
# get the controller
controller = GameLogic.getCurrentController()
# get the keyboard sensor named sensor
sen = controller.getSensor("sensor")
# Keyboard Sensor is using the All keys buttons
# get information about the key
pressed
keyInfo = sen.getPressedKeys()
# extract the keycode from the info
event = keyInfo[0][0]
# get the key name
key = GameKeys.EventToString(event)
Alphabet Keys
Number Keys
Shift Modifiers
LEFTALTKEY
LEFTCTRLKEY
LEFTSHIFTKEY
RIGHTALTKEY
RIGHTCTRLKEY
RIGHTSHIFTKEY
Arrow Keys
DOWNARROWKEY
LEFTARROWKEY
RIGHTARROWKEY
Numberpad Keys
PAD9
PADPERIOD
PADSLASHKEY
PADASTERKEY
PADMINUS
PADENTER
Function Keys
F10KEY
F11KEY
F12KEY
= 173
Other Keys
ACCENTGRAVEKEY
BACKSLASHKEY
BACKSPACEKEY
INSERTKEY
LEFTBRACKETKEY
LINEFEEDKEY
MINUSKEY
PAGEDOWNKEY
PAGEUPKEY
PAUSEKEY
PERIODKEY
QUOTEKEY
RIGHTBRACKETKEY
RETKEY
SEMICOLONKEY
Example: Assigning a key to a keyboard sensor
# import GameKeys module
import GameKeys
# get the current controller
controller = GameLogic.getCurrentController()
# get the keyboard sensor named assignKey
key = controller.getSensor("assignKey")
# Assign the A key to the keyboard sensor
key.setKey(GameKeys.AKEY)
AKEY
= 97
BKEY
= 98
CKEY
= 99
DKEY
= 100
EKEY
= 101
FKEY
= 102
GKEY
= 103
HKEY
= 104
IKEY
= 105
JKEY
= 106
KKEY
= 107
LKEY
= 108
MKEY
= 109
NKEY
= 110
OKEY
= 111
PKEY
= 112
QKEY
= 113
RKEY
= 114
SKEY
= 115
TKEY
= 116
UKEY
= 117
VKEY
= 118
WKEY
= 119
XKEY
= 120
Number Keys
ZEROKEY
= 48
ONEKEY
= 49
TWOKEY
= 50
THREEKEY
= 51
FOURKEY
= 52
FIVEKEY
= 53
SIXKEY
= 54
SEVENKEY
= 55
EIGHTKEY
= 56
Shift Modifiers
CAPSLOCKKEY
= ?
LEFTCTRLKEY
= 124
LEFTALTKEY
= 125
RIGHTALTKEY
= 126
RIGHTCTRLKEY
= 127
RIGHTSHIFTKEY
= 128
Arrow Keys
LEFTARROWKEY
= 143
DOWNARROWKEY
= 144
RIGHTARROWKEY
= 145
Numberpad Keys
PAD0
=158
PAD1
= 151
PAD2
= 147
PAD3
= 152
PAD4
= 148
PAD5
= 153
PAD6
= 149
PAD7
= 154
PAD8
= 150
PAD9
= 155
PADPERIOD
= 156
PADSLASHKEY
= 157
PADASTERKEY
= 42
PADMINUS
= 154
PADENTER
= 160
Function Keys
F1KEY
= 162
F2KEY
= 163
F3KEY
= 164
F4KEY
= 165
F5KEY
= 166
F6KEY
= 167
F7KEY
= 168
F8KEY
= 169
F9KEY
= 170
F10KEY
= 171
F11KEY
= 172
F12KEY
= 173
Other Keys
ACCENTGRAVEKEY
= 137
BACKSLASHKEY
= 139
BACKSPACEKEY
= 133
COMMAKEY
= 44
DELKEY
= 134
ENDKEY
= ?
EQUALKEY
= 140
ESCKEY
= 130
HOMEKEY
= 176
INSERTKEY
= 175
LEFTBRACKETKEY
= 141
LINEFEEDKEY
= ?
MINUSKEY
= 45
PAGEDOWNKEY
= 178
PAGEUPKEY
= 177
PAUSEKEY
= 174
PERIODKEY
= 46
QUOTEKEY
= 136
RIGHTBRACKETKEY
= 142
RETKEY
= 13
SEMICOLONKEY
= 135
SLASHKEY
= 138
SPACEKEY
= 32
TABKEY
= 131
|