Keyboard Sensor: targetProperty

targetProperty:
  • gets/sets the name of the String property that you added.
     
  • When the Log Toggle = True, All the keystrokes will be saved to Target Property (a string variable).
     
  • Keyboard Sensor name: Target

Type: 
  • string
Keyboard Sensor:
  • When the selected key is pressed, it sends one positive pulse to the connected controller(s).
     
  • When the selected key is released, it sends one negative pulse to the connected controller(s).
Sample Code


################  Get name of the string property

# import bge module
import bge

# get the controller
cont = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Gas

sen = cont.sensors["Gas"]

# get the target name
target_name = sen.targetProperty
 
Sample Code


################  Set name of the string property
 
# import bge module

import bge

# get the controller
controller = bge.logic.getCurrentController()

# get the sensor attached to the controller
# my sensor is named Gas

sen = controller.sensors["Gas"]

# set the target name
# my string Property name is Key_Log

sen.targetProperty = "Key_Log"