key let up functions

I am wanting a python script that says:

if L key is pressed
Then Set angular velocity to 2.5 around Z-axis

if L key is let up (specifically let up not just not being pressed)
Then Set angular velocity to 0.0 around z-axis

Else Don’t do anything

I am particularly interested in second “if” about the the L key being “just let up” and not just “not being pressed”

wow that is confusing to try to word:spin: I hope whoever reads this can understand it!:o

oh yah and if this can be done with logic brick instead of python please let me know!


setting 0.0 is ignored you need to set a small value like 0.001 at any axis.

I’m not sure if this is exactly what you need, but I would simply use two keyboard sensors:

Both checking for the “L”-Key, but one with both “Tap” and “Invert” enabled, which would be the “L key let up”-sensor and the other without anything enabled for “if L key is pressed”.
Connect them with two motion actuators, one with angV 2.5 and the other one, as Monster said, with a very small value of angV around the Z-axis.

Hope it helps,


I have tried that, but because the invert button is pressed it causes the “tap” button’s signal to be inverted, making it continuously apply the 0.01V instead of setting and letting friction stop it.

p.s. thank you for the replies i thought no one was gonna answer this post!:smiley:

If you use python, you can use a script something like in the attached file

[edit] or better yet, see Gomer’s post.


keyRelease.blend (132 KB)

Just press inv and tap on the sensor. This will cause the sensor to give off a pulse only on the first frame it is false. For a keyboard sensor, this happens to be the first frame it has been let go of.

Just a warning though, the sensor will give off a pulse on the first frame of the game, it can’t really be helped.

Hmm, for some reason I was under the impression that inv + tap causes it to give off a pulse on every frame except the first one it was pressed. I guess python is a bit excessive for such a simple problem, then ;]

thank you both captain oblivion and Gomer for the great advice. Capt oblivion’s script did the trick!