2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323...
[blender.git] / source / gameengine / PyDoc / GameKeys.py
1 # $Id$
2 """
3 Documentation for the GameKeys module.
4 ======================================
5
6 This module holds key constants for the SCA_KeyboardSensor.
7
8 Alphabet keys
9 -------------
10         - AKEY
11         - BKEY
12         - CKEY
13         - DKEY
14         - EKEY
15         - FKEY
16         - GKEY
17         - HKEY
18         - IKEY
19         - JKEY
20         - KKEY
21         - LKEY
22         - MKEY
23         - NKEY
24         - OKEY
25         - PKEY
26         - QKEY
27         - RKEY
28         - SKEY
29         - TKEY
30         - UKEY
31         - VKEY
32         - WKEY
33         - XKEY
34         - YKEY
35         - ZKEY
36
37 Number keys
38 -----------
39         - ZEROKEY
40         - ONEKEY
41         - TWOKEY
42         - THREEKEY
43         - FOURKEY
44         - FIVEKEY
45         - SIXKEY
46         - SEVENKEY
47         - EIGHTKEY
48         - NINEKEY
49
50 Shift Modifiers
51 ---------------
52         - CAPSLOCKKEY
53
54         - LEFTCTRLKEY
55         - LEFTALTKEY
56         - RIGHTALTKEY
57         - RIGHTCTRLKEY
58         - RIGHTSHIFTKEY
59         - LEFTSHIFTKEY
60
61 Arrow Keys
62 ----------
63         - LEFTARROWKEY
64         - DOWNARROWKEY
65         - RIGHTARROWKEY
66         - UPARROWKEY
67
68 Numberpad Keys
69 --------------
70         - PAD0
71         - PAD1
72         - PAD2
73         - PAD3
74         - PAD4
75         - PAD5
76         - PAD6
77         - PAD7
78         - PAD8
79         - PAD9
80         - PADPERIOD
81         - PADSLASHKEY
82         - PADASTERKEY
83         - PADMINUS
84         - PADENTER
85         - PADPLUSKEY
86
87 Function Keys
88 -------------
89         - F1KEY
90         - F2KEY
91         - F3KEY
92         - F4KEY
93         - F5KEY
94         - F6KEY
95         - F7KEY
96         - F8KEY
97         - F9KEY
98         - F10KEY
99         - F11KEY
100         - F12KEY
101
102 Other Keys
103 ----------
104         - ACCENTGRAVEKEY
105         - BACKSLASHKEY
106         - BACKSPACEKEY
107         - COMMAKEY
108         - DELKEY
109         - ENDKEY
110         - EQUALKEY
111         - ESCKEY
112         - HOMEKEY
113         - INSERTKEY
114         - LEFTBRACKETKEY
115         - LINEFEEDKEY
116         - MINUSKEY
117         - PAGEDOWNKEY
118         - PAGEUPKEY
119         - PAUSEKEY
120         - PERIODKEY
121         - QUOTEKEY
122         - RIGHTBRACKETKEY
123         - RETKEY
124         - SEMICOLONKEY
125         - SLASHKEY
126         - SPACEKEY
127         - TABKEY
128
129 Example::
130         # Set a connected keyboard sensor to accept F1
131         import GameLogic
132         import GameKeys
133         
134         co = GameLogic.getCurrentController()
135         # 'Keyboard' is a keyboard sensor
136         sensor = co.getSensor('Keyboard')
137         sensor.key = GameKeys.F1KEY
138
139 Example::
140         # Do the all keys thing
141         import GameLogic
142         import GameKeys
143         
144         co = GameLogic.getCurrentController()
145         # 'Keyboard' is a keyboard sensor
146         sensor = co.getSensor('Keyboard')
147         keylist = sensor.events
148         for key in keylist:
149                 # key[0] == GameKeys.keycode, key[1] = status
150                 if key[1] == GameLogic.KX_INPUT_JUST_ACTIVATED:
151                         if key[0] == GameKeys.WKEY:
152                                 # Activate Forward!
153                         if key[0] == GameKeys.SKEY:
154                                 # Activate Backward!
155                         if key[0] == GameKeys.AKEY:
156                                 # Activate Left!
157                         if key[0] == GameKeys.DKEY:
158                                 # Activate Right!
159                 
160 """
161
162 def EventToString(event):
163         """
164         Return the string name of a key event. Will raise a ValueError error if its invalid.
165         
166         @type event: int
167         @param event: key event from GameKeys or the keyboard sensor.
168         @rtype: string
169         """
170         
171 def EventToCharacter(event, shift):
172         """
173         Return the string name of a key event. Returns an empty string if the event cant be represented as a character.
174         
175         @type event: int
176         @param event: key event from GameKeys or the keyboard sensor.
177         @type event: bool
178         @param event: set to true if shift is held.
179         @rtype: string
180         """
181