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