Nov 2, 2002 #1 Bygbobbo Programmer Joined Apr 23, 2002 Messages 145 Location US I am trying to trap the keydown and keyup from an applet... Can anyone give me some advice/sample... THanks in advance, Bygs
I am trying to trap the keydown and keyup from an applet... Can anyone give me some advice/sample... THanks in advance, Bygs
Nov 2, 2002 #2 MarsChelios Programmer Joined Oct 20, 2002 Messages 66 Location US Hi Bygbobbo, The easiest way to get the event when a button has been clicked is to use Code: KeyListener s. Simply implement the Code: KeyListener interface and add it to the component(s) you'd like to listen to Code: KeyEvent s on via the Code: addKeyListener (KeyListener) method. Like this: Code: someComponent.addKeyListener (someKeyListener); The methods required to implement the KeyListener are as follows: Code: public void keyTyped (KeyEvent event) {} public void keyPressed (KeyEvent event) {} public void keyReleased (KeyEvent event) {} The Code: KeyEvent object can give you all the data you need, including modifiers like alt, ctrl, etc. Hope this Helps, MarsChelios Upvote 0 Downvote
Hi Bygbobbo, The easiest way to get the event when a button has been clicked is to use Code: KeyListener s. Simply implement the Code: KeyListener interface and add it to the component(s) you'd like to listen to Code: KeyEvent s on via the Code: addKeyListener (KeyListener) method. Like this: Code: someComponent.addKeyListener (someKeyListener); The methods required to implement the KeyListener are as follows: Code: public void keyTyped (KeyEvent event) {} public void keyPressed (KeyEvent event) {} public void keyReleased (KeyEvent event) {} The Code: KeyEvent object can give you all the data you need, including modifiers like alt, ctrl, etc. Hope this Helps, MarsChelios
Nov 2, 2002 Thread starter #3 Bygbobbo Programmer Joined Apr 23, 2002 Messages 145 Location US yes it does help.. I was having a problem of where to add the: addKeyListener(this); I put this in the init() Im grabbing all the keys that i need now thanks Bygs ) Upvote 0 Downvote
yes it does help.. I was having a problem of where to add the: addKeyListener(this); I put this in the init() Im grabbing all the keys that i need now thanks Bygs )