Keyboard Sensor: hold1

hold1
  • gets/sets the key assigned to First Modifier
     
  • Keyboard Sensor name:  First Modifier

Type:
  • Type:  integer
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 the key currently assigned to First Modifier
 
# 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 key assigned to First Modifier
first_mod = sen.hold1
 
Sample Code


################  Set the key currently assigned to First Modifier
 
# 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"]

# Assign left Ctrl key to First Modifier
# Key Code for the left Ctrl key is 124
sen.hold1 = 124