Keypress questions (Active window and 'If' Statements)

Mar 31, 2013 at 10:41am

Keypress questions (Active window and 'If' Statements)

Hello, I am creating a patch that uses the keys of the computer keyboard in order for the user to navigate in a 3D world. I apologize if these questions were already answered, but I could not find an answer that I understood.

My first question:
How would I enable a keypress to work even if the active window isn’t the patcher? Similar to this person’s question: http://www.cycling74.com/forums/topic.php?id=17878 , but I’m not sure what’s helpful in that page. I want to be able to activate keys for a 3d environment to change, but it only works so far if the patcher itself is the active window.

Second Question:
I want the user to be unable to change the environment in a certain way if a certain key hadn’t been pressed prior. I have a vague idea of “if” statements, but I am unclear as to its application and would appreciate a sample patch.

For example, my patch would change if I pressed the “O” and “P” keys, but I don’t want “P” to change the patch if “O” had not been pressed first.

I can post a project file of what I have so far, but it is very unorganized so far.

#67443
Mar 31, 2013 at 2:25pm

As far as I know, the [key] object works even if it’s not on the active patcher. However it doesn’t work is MAX isn’t the active programme, and I wouldn’t know how to go around this.

About the second question, here’s one way to do it:

– Pasted Max Patch, click to expand. –

(if you want the key presses to be done within a specific time limit, you can use a [del] object to close the [gate] if letter “P” hasn’t been pressed within n seconds, or whatever.

#242629
Apr 1, 2013 at 3:39am

I am tweaking around with the patch you gave me. So far it is looking alright. Thank you.

As for my first question:
Yes, the [key] object does work but it doesn’t send a bang like it would if I made the patcher window the active window. What I need is for tthe keys to register whilst the active window is the 3d render.The [key] object is only directly connected to a number box which is connected to a [sel] object.

#242630
Apr 1, 2013 at 7:38am

In my Max, [key] also bangs if it’s not the active window.

But in any case if the 3D render window is in Max/MSP/Jitter, then you could simply add a [key] connected to a [send lol] object on that window, and have a [receive lol] connected to a number box in your main patcher, and that should do the trick. :)

#242631
Apr 1, 2013 at 8:07am

Thank you for the input, but the 3d render window isn’t a kind that can be edited in that way. I will be sure to use this technique in the future though.

Here’s a screen shot:

http://i.imgur.com/JXhN5T7.png

The window labelled: “myworld” is the active window that has to be eventually full-screened. :)

#242632

You must be logged in to reply to this topic.