We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
KeyPressing (Read 262 times)
KeyPressing
Mar 21st, 2009, 1:05am
 
How would i make it so if i type W an action happens? I've looked at the keyobard tutorials but they don't seem to have the code i'm looking for.
Re: KeyPressing
Reply #1 - Mar 21st, 2009, 9:07am
 
I think you need to look at keyPressed() function and siblings. If they don't fit your needs, you should explain them more.
Re: KeyPressing
Reply #2 - Mar 21st, 2009, 10:57am
 
Sorry for not specifying.

I ment what do you type to create an event when a certain letter is typed.
Re: KeyPressing
Reply #3 - Mar 21st, 2009, 12:37pm
 
if you click the link, and then click the related links at the bottom, you end up here;
http://processing.org/reference/key.html

that should give you the information you need..

combine the two and you get something like
void keyPressed()
{
if ( key == 'w' || key == 'W') {
 println("hello world");
}
}
Page Index Toggle Pages: 1