• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

KeyPress event

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I 've made a applet which listens to key press event. This is working sucessfully, but now i want my applet to respond to the combinations of keys.
For example, so far the applet responds on the click of 'key down' arrow key. now i want the applet to respond when usr clicks
'alt+n'.
My problem is , as we can get the keycode for 'key down' arrow key, how can we get the keycode for combinations of keys.
following is the simplified form of my code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
//<html>
//<applet code=KeyStroke width= 200 height=200>
//</applet>
//</html>
public class KeyStroke extends Applet implements KeyListener{
Button b1 = new Button("Press Me");
Button b2 = new Button("Press Me too");
List l1 = new List();
public void start(){
requestFocus();
add(b1);
add(b2);
l1.add("melbourne");
l1.add("Brisbane");
l1.add("Sydney");
add(l1);
add(new Button("shikhar"));
addKeyListener(this);
setSize(100,100);
}
public void keyPressed(KeyEvent e){
int t = e.getKeyCode();
if(t==e.VK_DOWN)
System.out.println("DOWN MOUSE CLICKED");
}
public void keyReleased(KeyEvent e){
}
public void keyTyped(KeyEvent e){
}
}

thanks a lot for the patience..
Hope to get response..
Shikhar

 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shikhar,
This class may help.
Marilyn
 
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic