[SOLVED?] Python & MouseKeyboard

For questions about using Classic.

Post » Tue Sep 17, 2013 2:42 pm

I have a curious question. How does the Mouse&Keyboard work with Python? I'm trying to capture some of the input keys and stumbled upon the MouseKeyboard.OnAnyKey() option, which might be useful for this. There's no MouseKeyboard.LastKeyPressed, so I'm going the other way around. Let's say I have this:

How am I supposed to use this? Is it something like:
    myText.SetText("key pressed!")[/CODE]

def dostuff():
    myText.SetText("key pressed!")[/CODE]

Any help appreciated, I'll try to experiment with this on my own in the meantime. :)

Edit: I was able to make it somehow work, by using
[CODE]if MouseKeyboard.OnAnyKey():
     if MouseKeyboard.OnKey(get.key("key_config","select")):
          debug.SetText("select pressed")
     elif MouseKeyboard.OnKey(get.key("key_config","cancel")):
          debug.SetText("cancel pressed")[/CODE]
But it seems to work only with VK_ keys, according to this post: http://www.scirra.com/forum/construct-keyboard-in-python_topic39918.html
That is: I can test for space button, or the Numpad buttons, but no A, S, D keys and so on. Any way to do this?

Thanks in advance!

Edit#2: Well, it seems a light fever helped me find the solution. The keys mentioned in that mapping thread are 0-indexed, so that I had to subtract 1 from every each value I wanted to map. Now it works like a charm, I think.bitworks2013-09-17 15:07:42
Posts: 28
Reputation: 435

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests