Module GameTypes :: Class SCA_KeyboardSensor
[hide private]
[frames] | no frames]

Class SCA_KeyboardSensor

source code

PyObjectPlus --+            
               |            
          CValue --+        
                   |        
     SCA_ILogicBrick --+    
                       |    
             SCA_ISensor --+
                           |
                          SCA_KeyboardSensor

A keyboard sensor detects player key presses.

See module GameKeys for keycode values.

Instance Methods [hide private]
key state GameLogic members (KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED)
getKeyStatus(keycode)
Get the status of a key.
source code
    Deprecated
keycode from GameKeys module
getKey()
Returns the key code this sensor is looking for.
source code
 
setKey(keycode)
Set the key this sensor should listen for.
source code
keycode from GameKeys module
getHold1()
Returns the key code for the first modifier this sensor is looking for.
source code
 
setHold1(keycode)
Sets the key code for the first modifier this sensor should look for.
source code
keycode from GameKeys module
getHold2()
Returns the key code for the second modifier this sensor is looking for.
source code
 
setHold2(keycode)
Sets the key code for the second modifier this sensor should look for.
source code
list of key status. [[keycode, status]]
getPressedKeys()
Get a list of keys that have either been pressed, or just released this frame.
source code
list of key status. [[keycode, status]]
getCurrentlyPressedKeys()
Get a list of currently pressed keys that have either been pressed, or just released
source code
    Inherited from SCA_ISensor
 
reset()
Reset sensor internal state, effect depends on the type of sensor and settings.
source code
integer
getFrequency()
The frequency for pulse mode sensors.
source code
 
getInvert()
True if this sensor activates on negative events.
source code
boolean
getLevel()
Returns whether this sensor is a level detector or a edge detector.
source code
 
getUseNegPulseMode()
True if the sensor is in negative pulse mode.
source code
 
getUsePosPulseMode()
True if the sensor is in positive pulse mode.
source code
 
isPositive()
True if this sensor brick is in a positive state.
source code
 
isTriggered()
True if this sensor brick has triggered the current controller.
source code
 
setFrequency(freq)
Sets the frequency for pulse mode sensors.
source code
 
setInvert(invert)
Sets if this sensor activates on positive or negative events.
source code
 
setLevel(level)
Set whether to detect level or edge transition when entering a state.
source code
 
setUseNegPulseMode(pulse)
Sets negative pulse mode.
source code
 
setUsePosPulseMode(pulse)
Sets positive pulse mode.
source code
    Inherited from SCA_ILogicBrick
integer
getExecutePriority()
Gets the execution priority of this logic brick.
source code
KX_GameObject
getOwner()
Gets the game object associated with this logic brick.
source code
 
setExecutePriority(priority)
Sets the priority of this logic brick.
source code
    Inherited from CValue
string
getName()
Returns the name of the CValue.
source code
    Inherited from PyObjectPlus
bool
isA(game_type)
Check if this is a type or a subtype game_type.
source code
Instance Variables [hide private]
list [[keycode, status], ...] events
a list of pressed keys that have either been pressed, or just released, or are active this frame.
keycode from GameKeys module hold1
The key code for the first modifier this sensor is looking for.
keycode from GameKeys module hold2
The key code for the second modifier this sensor is looking for.
keycode from GameKeys module key
The key code this sensor is looking for.
string targetProperty
The name of the property that receives keystrokes in case in case a string is logged.
string toggleProperty
The name of the property that indicates whether or not to log keystrokes as a string.
boolean useAllKeys
Flag to determine whether or not to accept all keys.
    Inherited from SCA_ISensor
int frequency
The frequency for pulse mode sensors.
boolean invert
Flag to set if this sensor activates on positive or negative events.
boolean level
Option whether to detect level or edge transition when entering a state.
boolean positive
True if this sensor brick is in a positive state.
boolean tap
When enabled only sensors that are just activated will send a positive event, after this they will be detected as negative by the controllers.
boolean triggered
True if this sensor brick is in a positive state.
boolean useNegPulseMode
Flag to turn negative pulse mode on and off.
boolean usePosPulseMode
Flag to turn positive pulse mode on and off.
    Inherited from SCA_ILogicBrick
int executePriority
This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
string name
The name of this CValue derived object (read-only).
KX_GameObject or None in exceptional cases. owner
The game object this logic brick is attached to (read-only).
    Inherited from PyObjectPlus
bool invalid
Test if the object has been freed by the game engine and is no longer valid.
Method Details [hide private]

getKeyStatus(keycode)

source code 
Get the status of a key.
Parameters:
  • keycode (integer) - The code that represents the key you want to get the state of
Returns: key state GameLogic members (KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED)
The state of the given key

getKey()

source code 
Returns the key code this sensor is looking for.
Returns: keycode from GameKeys module

Deprecated: Use the key attribute instead.

setKey(keycode)

source code 
Set the key this sensor should listen for.

Deprecated: Use the key attribute instead.

getHold1()

source code 
Returns the key code for the first modifier this sensor is looking for.
Returns: keycode from GameKeys module

Deprecated: Use the hold1 attribute instead.

setHold1(keycode)

source code 
Sets the key code for the first modifier this sensor should look for.

Deprecated: Use the hold1 attribute instead.

getHold2()

source code 
Returns the key code for the second modifier this sensor is looking for.
Returns: keycode from GameKeys module

Deprecated: Use the hold2 attribute instead.

setHold2(keycode)

source code 
Sets the key code for the second modifier this sensor should look for.

Deprecated: Use the hold2 attribute instead.

getPressedKeys()

source code 
Get a list of keys that have either been pressed, or just released this frame.
Returns: list of key status. [[keycode, status]]

Deprecated: Use the events attribute instead.

getCurrentlyPressedKeys()

source code 
Get a list of currently pressed keys that have either been pressed, or just released
Returns: list of key status. [[keycode, status]]

Deprecated: Use the events attribute instead.


Instance Variable Details [hide private]

events

a list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
Type:
list [[keycode, status], ...]