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.
IndexProgramming Questions & HelpSyntax Questions › Detecting "page up" key pressed
Page Index Toggle Pages: 1
Detecting "page up" key pressed (Read 898 times)
Detecting "page up" key pressed
Feb 21st, 2009, 10:40am
 
I found a way for detecting when the LEFT key got pressed:

void draw() {
   if(keyPressed) {
     print("key: "); println(key);
   if(keyCode==LEFT) { println("LEFT"); }
}

but how do I detect page up?
It would be easy if I could just compare the keycode with some universal code representing "PAGE UP" instead of having to figure out its correct keyword (it's neither PAGEUP nor PGUP - and I can't find a list of these keywords)
Re: Detecting "page up" key pressed
Reply #1 - Feb 21st, 2009, 11:02am
 
Actually, all the supported special keys are documented in keyCode reference...
In the source code of Processing, I see the comment:
Quote:
 // only including the most-used of these guys
 // if people need more esoteric keys, they can learn about
 // the esoteric java KeyEvent api and of virtual keys

So I did:
Code:
void keyPressed()
{
if (keyCode == KeyEvent.VK_PAGE_UP)
println("PGUP");
else if (keyCode == KeyEvent.VK_PAGE_DOWN)
println("PGDN");
}
Re: Detecting "page up" key pressed
Reply #2 - Feb 21st, 2009, 1:46pm
 
Quote:
Actually, all the supported special keys are documented in keyCode reference...

It would be nice if the keyCode reference made it clear that the few keywords it mentions in different places actually is the complete list of non-visual characters that can be catched from the ascii-table
Code:
KeyEvent.VK_PAGE_UP)
KeyEvent.VK_PAGE_DOWN)

And for future reference: A bunch of others of theese special keyCodes can be found here
Re: Detecting "page up" key pressed
Reply #3 - Feb 21st, 2009, 4:49pm
 
Actually, (without looking at the page you link to!), the authoritative, complete reference for this is at KeyEvent.
Page Index Toggle Pages: 1