FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Bug Fixes, Implemented Suggestions
(Moderator: fry)
   KeyPressed() vs KeyPressed(KeyEvent e)
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: KeyPressed() vs KeyPressed(KeyEvent e)  (Read 3459 times)
Eben Eliason
Guest
Email
KeyPressed() vs KeyPressed(KeyEvent e)
« on: May 1st, 2004, 12:13pm »

Hey-
 
I'm implementing some text input and having some trouble.  I based my first version on the "Typing" example in the Learning section.  Since then I've also added horizontal scrolling and a cursor that reacts to the arrow keys.  Everything is smooth with ONE exceptoin:
 
The 'key' field in the default keyPressed() method contains code 39 for both the right arrow AND the apostrophe, and so the right arrow overrides the apostrphe.
 
I tried implementing my own listener, which solved the overlap problem (right arrow returns true for isActionKey() method), but I also end up with 8-bit ASCII for the rest of the keyCodes which aren't supported in processing, so that just causes more hassles.
 
Any ideas on how I can use the default method to detect which key is actually pressed?  Or, contrarywise, how to convert the remainder of the keycodes in my own listener class to the supported charset?
 
THANKS!
 
-Eben
 
fry


WWW
Re: KeyPressed() vs KeyPressed(KeyEvent e)
« Reply #1 on: May 1st, 2004, 5:02pm »

if you're having trouble with keyPressed(), you can get anything and everything out of keyPressed(KeyEvent e), in which case you just use the java methods and constants for handling all the keys.
 
the key codes are things like KeyEvent.VK_ENTER, you can find the full listing in sun's java docs. fwiw, the codes are 16 bit, actually, ascii is only 7 bit.
 
Eben Eliason
Guest
Email
Re: KeyPressed() vs KeyPressed(KeyEvent e)
« Reply #2 on: May 1st, 2004, 5:20pm »

Yeah, I guess I could do that.  It seems like a lot of work though, because I will have to maintain state for special keys like CAPS, handle modifiers like SHIFT, etc.
 
Basically, I mean to suggest that an extra field be added to the keyPressed() method in future versions if possible.
 
A boolean  for isActionKey() would suffice...and save me lots of time.
 
fry


WWW
Re: KeyPressed() vs KeyPressed(KeyEvent e)
« Reply #3 on: May 4th, 2004, 12:51am »

i think there are two things, and part of what you're talking about is a bug, which i'll look into. 'key' should/shouldn't be set on isActionKey, so rather than having keyPressed() fire all the time, a better tactic is needed.
 
i'll be doing some work on the key handling soon, so i'll make a note to look into it further.
 
fry


WWW
Re: KeyPressed() vs KeyPressed(KeyEvent e)
« Reply #4 on: Sep 20th, 2004, 11:54pm »

fixed for megabucket.
 
Pages: 1 

« Previous topic | Next topic »