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 & HelpOpenGL and 3D Libraries › Activate Keyboard Listener right after Applet load
Page Index Toggle Pages: 1
Activate Keyboard Listener right after Applet load (Read 744 times)
Activate Keyboard Listener right after Applet load
Oct 21st, 2007, 9:25pm
 
When I start the processing applet in PDE, I have to mouse click on the applet first, then the keyPressed() will start working.

If I don't mouse click once on the applet, keyboard event will not work. No matter i press on keyboard the Applet just don't get any events.

Any way I can start listen Keyboard event right after applet started?
Re: Activate Keyboard Listener right after Applet
Reply #1 - Oct 22nd, 2007, 12:55am
 
I think that is a Focus problem you are having there.

I'm not verry familiar with that particular concept, but i've made a few applets and they usualy needed to be pressed once before they could receive keyboard input.

There are probably a few threads discussing that problem. Try to find something about focus, and try some soluction. Maybe your problem will be solved.

[edit] - but this section is probably the wrong place for you to ask or search this... but then again, no idea.
Re: Activate Keyboard Listener right after Applet
Reply #2 - Oct 22nd, 2007, 2:09pm
 
Also see this old blog post with a possible solution:
http://toxi.co.uk/blog/2004/01/automatic-keyboard-focus.htm

(just replace loop() with draw(), this was originally written for Processing ALPHA, still will work though...)
Page Index Toggle Pages: 1