[SOLVED?] Python & MouseKeyboard

This forum is currently in read-only mode.
  • 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!")


    def dostuff():
        myText.SetText("key pressed!")

    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

    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")

    But it seems to work only with VK_ keys, according to this post: 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)