A bit of bge.events work:
authorMitchell Stokes <mogurijin@gmail.com>
Tue, 5 Oct 2010 05:44:15 +0000 (05:44 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Tue, 5 Oct 2010 05:44:15 +0000 (05:44 +0000)
  * A few places in the bge.events docs mentioned bge.keys, when it should have been bge.events
  * Created two aliases to bge.events.RETKEY: ENTERKEY and RETURNKEY
  * ENTERKEY and RETURNKEY have been added to the docs and RETKEY marked as deprecated
  * Added an example of using bge.logic.keyboard to the bge.events docs

source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/PyDoc/bge.events.rst

index a6b2453f0c5225d2ea3b2e0ffb328fb85b3e7f12..473e6fc92657a75478d1eebb53271f85b719abc0 100644 (file)
@@ -2214,6 +2214,8 @@ PyObject* initGameKeys()
        KX_MACRO_addTypesToDict(d, ESCKEY, SCA_IInputDevice::KX_ESCKEY);
        KX_MACRO_addTypesToDict(d, TABKEY, SCA_IInputDevice::KX_TABKEY);
        KX_MACRO_addTypesToDict(d, RETKEY, SCA_IInputDevice::KX_RETKEY);
+       KX_MACRO_addTypesToDict(d, ENTERKEY, SCA_IInputDevice::KX_RETKEY);
+       KX_MACRO_addTypesToDict(d, RETURNKEY, SCA_IInputDevice::KX_RETKEY);
        KX_MACRO_addTypesToDict(d, SPACEKEY, SCA_IInputDevice::KX_SPACEKEY);
        KX_MACRO_addTypesToDict(d, LINEFEEDKEY, SCA_IInputDevice::KX_LINEFEEDKEY);              
        KX_MACRO_addTypesToDict(d, BACKSPACEKEY, SCA_IInputDevice::KX_BACKSPACEKEY);
index f642291fe975fd7e24453ec5c4fbb1556bda8681..5738e7a0f486817a5df010a7f297596d4609c7e8 100644 (file)
@@ -18,7 +18,7 @@ This module holds key constants for the SCA_KeyboardSensor.
        co = bge.logic.getCurrentController()
        # 'Keyboard' is a keyboard sensor
        sensor = co.sensors["Keyboard"]
-       sensor.key = bge.keys.F1KEY
+       sensor.key = bge.events.F1KEY
 
 .. code-block:: python
 
@@ -30,17 +30,37 @@ This module holds key constants for the SCA_KeyboardSensor.
        sensor = co.sensors["Keyboard"]
 
        for key,status in sensor.events:
-               # key[0] == bge.keys.keycode, key[1] = status
+               # key[0] == bge.events.keycode, key[1] = status
                if status == bge.logic.KX_INPUT_JUST_ACTIVATED:
-                       if key == bge.keys.WKEY:
+                       if key == bge.events.WKEY:
                                # Activate Forward!
-                       if key == bge.keys.SKEY:
+                       if key == bge.events.SKEY:
                                # Activate Backward!
-                       if key == bge.keys.AKEY:
+                       if key == bge.events.AKEY:
                                # Activate Left!
-                       if key == bge.keys.DKEY:
+                       if key == bge.events.DKEY:
                                # Activate Right!
 
+.. code-block:: python
+
+       # The all keys thing without a keyboard sensor (but you will
+       # need an always sensor with pulse mode on)
+       import bge
+       
+       # Just shortening names here
+       keyboard = bge.logic.keyboard
+       JUST_ACTIVATED = bge.logic.KX_INPUT_JUST_ACTIVATED
+       
+       if keyboard.events[bge.events.WKEY] == JUST_ACTIVATED:
+               print("Activate Forward!")
+       if keyboard.events[bge.events.SKEY] == JUST_ACTIVATED:
+               print("Activate Backward!")     
+       if keyboard.events[bge.events.AKEY] == JUST_ACTIVATED:
+               print("Activate Left!") 
+       if keyboard.events[bge.events.DKEY] == JUST_ACTIVATED:
+               print("Activate Right!")
+               
+
 *********
 Functions
 *********
@@ -222,7 +242,9 @@ Other Keys
 .. data:: PERIODKEY
 .. data:: QUOTEKEY
 .. data:: RIGHTBRACKETKEY
-.. data:: RETKEY
+.. data:: RETKEY (Deprecated: use bge.events.ENTERKEY or bge.events.RETURNKEY)
+.. data:: ENTERKEY
+.. data:: RETURNKEY
 .. data:: SEMICOLONKEY
 .. data:: SLASHKEY
 .. data:: SPACEKEY