Multiple Actions Per Key

What I did was define a Function that would do something different depending on the keyboard key pressed.

The Function works, however, when I press another key while still pressing the first one (repeat is set), the Function executes the action of the second key press and end the action of the first key, which is still being held.

Can anyone tell me how to get parallel actions going at once?
(hopefully I don’t have to get into threading)

I wouldn’t listen to the repeat event, but only to key-down and key-up. Roaming Ralph does this as well, if i recall correctly.

In practice you store the key when it is pressed and first remove it from the list when you recieve the key-up event. All tasks have to look up the values in that list/dict instead of waiting for an event, of course.

you could try making a task for the events.

when the first key is pressed, it starts the task and when the first key is let go it ends it.

def action1(self):
     #your code here
     if self.bool:
          return Task.cont
          return task.done

the boolean would be set to True when you start the task and when the key is let go the boolean would be false. You have to make sure that the “-up” event is in your code

EDIT: looks like i was beaten to the response

I think you gave me a different Idea with that not listening to the keyrepeat.

I’m going to try something that just popped up in my head.

Here goes nothing… :wink:

One question… When you stop a task with “done”, does that mean the defined task is still in the taskMgr, but just not active or does it mean the task has been deleted from taskMgr?

Its removed from the taskMgr, so you would have to call taskMgr.add

Thanks. :stuck_out_tongue:

Yaaayyyyyy!!! Lmao! 8)

Solved it!

Anyone knows how to kill the motion blurr of a Moving object? I did a test with Intervs. and I was able to move an instance smoothly. Using Intervs is a “beeoch” because you would want the object to stop when the key is released. I’ve been unsuccessful in trying to get the Intervs to stop in my test; which is probably due to the fact I created multiple Intervs instances and didn’t stop the right one. …I’m lost.