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

Class SCA_KeyboardSensor

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

A keyboard sensor detects player key presses.

See module GameKeys for keycode values.

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

getKeyStatus(keycode)

 

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()

 

Returns the key code this sensor is looking for.

Returns: keycode from GameKeys module

Deprecated: Use the key attribute instead.

setKey(keycode)

 

Set the key this sensor should listen for.

Parameters:
  • keycode (keycode from GameKeys module)

Deprecated: Use the key attribute instead.

getHold1()

 

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)

 

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

Parameters:
  • keycode (keycode from GameKeys module)

Deprecated: Use the hold1 attribute instead.

getHold2()

 

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)

 

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

Parameters:
  • keycode (keycode from GameKeys module)

Deprecated: Use the hold2 attribute instead.

getPressedKeys()

 

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()

 

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

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], ...]