Keyboard sensor question


I am looking for a detailed description of the keyboard sensor.
Want to find out wether it is responsible for the following:

Console output apears twice.(When ‘pressing’, as well as when ‘releasing’ the related key)



All keyboards send two signals per key: the make code when the key is pressed and the break code when released. This usually translates to the key-down and key-up sensor events.

If you don’t want double of everything, make sure not to print the key in one of the events.

Hope this helps.

Duoas thank you.

You wrote: ‘If you don’t want double of everything, make sure not to print the key in one of the events.’

Is this related with the Pulse Mode Buttons settings of the keyboard sensor?
Or how else should I make sure NOT to print the key in one of the events?


Double output on console doesn’t have anything to do with keyboard sensors and keyboard events. It happens because every change of any sensor causes running of controller script. You have to check in controller script, if condition for running script is met.
For example script is run when all sensors are active:

contr = GameLogic.getCurrentController()
for sens in contr.getSensors():
  if not sens.isPositive(): break
  # rest of the script
  print 'running script'

Thanks ashid, I shall look into that.


I can’t get it to work because I miss the clue of what you are telling me.
Maybe you would be so kind to point me to some documentaion involved.

With respect,


SCA_ISensor documentation
If you replace line after “# rest of the script” from my example with your actual script (properly intended), it will be executed only when key will be pressed.

Sorry Ashid for delay,

Can’t get it going yet, but I’ll keep trying.

Thank you for documentation.