Keyboard Sensor: hold2

hold2
  • gets/sets the key assigned to Second Modifier
     
  • Keyboard Sensor name:  Second 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 Second 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 Second Modifier
second_mod = sen.hold2
 
Sample Code


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

# Assign left Alt key to Second Modifier
# Key Code for the left Alt key is 125
sen.hold2 = 125