Welcome to mirror list, hosted at ThFree Co, Russian Federation.

GameKeys.py « PyDoc « gameengine « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 310f2b0d5061b091503f7dfe577c5ce672d2676b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# $Id$
"""
Documentation for the GameKeys module.
======================================

This module holds key constants for the SCA_KeyboardSensor.

Alphabet keys
-------------
	- AKEY
	- BKEY
	- CKEY
	- DKEY
	- EKEY
	- FKEY
	- GKEY
	- HKEY
	- IKEY
	- JKEY
	- KKEY
	- LKEY
	- MKEY
	- NKEY
	- OKEY
	- PKEY
	- QKEY
	- RKEY
	- SKEY
	- TKEY
	- UKEY
	- VKEY
	- WKEY
	- XKEY
	- YKEY
	- ZKEY

Number keys
-----------
	- ZEROKEY
	- ONEKEY
	- TWOKEY
	- THREEKEY
	- FOURKEY
	- FIVEKEY
	- SIXKEY
	- SEVENKEY
	- EIGHTKEY
	- NINEKEY

Shift Modifiers
---------------
	- CAPSLOCKKEY

	- LEFTCTRLKEY
	- LEFTALTKEY
	- RIGHTALTKEY
	- RIGHTCTRLKEY
	- RIGHTSHIFTKEY
	- LEFTSHIFTKEY

Arrow Keys
----------
	- LEFTARROWKEY
	- DOWNARROWKEY
	- RIGHTARROWKEY
	- UPARROWKEY

Numberpad Keys
--------------
	- PAD0
	- PAD1
	- PAD2
	- PAD3
	- PAD4
	- PAD5
	- PAD6
	- PAD7
	- PAD8
	- PAD9
	- PADPERIOD
	- PADSLASHKEY
	- PADASTERKEY
	- PADMINUS
	- PADENTER
	- PADPLUSKEY

Function Keys
-------------
	- F1KEY
	- F2KEY
	- F3KEY
	- F4KEY
	- F5KEY
	- F6KEY
	- F7KEY
	- F8KEY
	- F9KEY
	- F10KEY
	- F11KEY
	- F12KEY

Other Keys
----------
	- ACCENTGRAVEKEY
	- BACKSLASHKEY
	- BACKSPACEKEY
	- COMMAKEY
	- DELKEY
	- ENDKEY
	- EQUALKEY
	- ESCKEY
	- HOMEKEY
	- INSERTKEY
	- LEFTBRACKETKEY
	- LINEFEEDKEY
	- MINUSKEY
	- PAGEDOWNKEY
	- PAGEUPKEY
	- PAUSEKEY
	- PERIODKEY
	- QUOTEKEY
	- RIGHTBRACKETKEY
	- RETKEY
	- SEMICOLONKEY
	- SLASHKEY
	- SPACEKEY
	- TABKEY

Example::
	# Set a connected keyboard sensor to accept F1
	import GameLogic
	import GameKeys
	
	co = GameLogic.getCurrentController()
	# 'Keyboard' is a keyboard sensor
	sensor = co.getSensor('Keyboard')
	sensor.key = GameKeys.F1KEY

Example::
	# Do the all keys thing
	import GameLogic
	import GameKeys
	
	co = GameLogic.getCurrentController()
	# 'Keyboard' is a keyboard sensor
	sensor = co.getSensor('Keyboard')
	keylist = sensor.events
	for key in keylist:
		# key[0] == GameKeys.keycode, key[1] = status
		if key[1] == GameLogic.KX_INPUT_JUST_ACTIVATED:
			if key[0] == GameKeys.WKEY:
				# Activate Forward!
			if key[0] == GameKeys.SKEY:
				# Activate Backward!
			if key[0] == GameKeys.AKEY:
				# Activate Left!
			if key[0] == GameKeys.DKEY:
				# Activate Right!
		
"""

def EventToString(event):
	"""
	Return the string name of a key event. Will raise a ValueError error if its invalid.
	
	@type event: int
	@param event: key event from GameKeys or the keyboard sensor.
	@rtype: string
	"""
	
def EventToCharacter(event, shift):
	"""
	Return the string name of a key event. Returns an empty string if the event cant be represented as a character.
	
	@type event: int
	@param event: key event from GameKeys or the keyboard sensor.
	@type event: bool
	@param event: set to true if shift is held.
	@rtype: string
	"""