Module GameKeys

Source Code for Module GameKeys

  1  # $Id: GameKeys.py 2717 2004-06-26 09:15:41Z kester $ 
  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.setKey(GameKeys.F1KEY) 
138   
139  Example:: 
140          # Do the all keys thing 
141          import GameLogic 
142          import GameKeys 
143   
144          # status: these should be added to a module somewhere 
145          KX_NO_INPUTSTATUS = 0 
146          KX_JUSTACTIVATED = 1 
147          KX_ACTIVE = 2 
148          KX_JUSTRELEASED = 3 
149                   
150          co = GameLogic.getCurrentController() 
151          # 'Keyboard' is a keyboard sensor 
152          sensor = co.getSensor('Keyboard') 
153          keylist = sensor.getPressedKeys() 
154          for key in keylist: 
155                  # key[0] == GameKeys.keycode, key[1] = status 
156                  if key[1] == KX_JUSTACTIVATED: 
157                          if key[0] == GameKeys.WKEY: 
158                                  # Activate Forward! 
159                          if key[0] == GameKeys.SKEY: 
160                                  # Activate Backward! 
161                          if key[0] == GameKeys.AKEY: 
162                                  # Activate Left! 
163                          if key[0] == GameKeys.DKEY: 
164                                  # Activate Right! 
165                   
166  """ 
167