Advertisement

[java] Keyboard input

Started by November 11, 2000 06:04 PM
1 comment, last by Lord Chaos 24 years, 1 month ago
In my applet, I want to monitor keyboard input. So I implement the KeyListener interface public MyApplet extends Applet implements KeyListener { public MyApplet() {} public void init() { addKeyListener( this ); } public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) {} } Yes, I do stuff in the keyTyped and other methods, i just cut it out to make the code block a bit smaller Anyway, it doesn''t work! I never recieve any KeyEvent:s and the key* methods never gets called. (I also use the MouseListener with its corresponding methods (addMouseListener, mouseClicked and so on), and that works fine) Have I missed something? Is there any other way to get keyboard input notification?
-------------------------------------------------------------LGPL 3D engine - http://www.sourceforge.net/projects/realityengine
Yeah, you''re forgetting to call requestFocus() - either call it in the init() method or when the user clicks on the applet.

JP.

==============================================
I feel like a kid in some kind of store...
==============================================
www.thejpsystem.com
==============================================I feel like a kid in some kind of store... ============================================== www.thejpsystem.com
Advertisement
Thanks, that did the trick!
-------------------------------------------------------------LGPL 3D engine - http://www.sourceforge.net/projects/realityengine

This topic is closed to new replies.

Advertisement