import javax.swing.*;
import java.awt.event.*;
public class YQuestions extends JFrame implements KeyListener
{
YQuestions(){
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(500,500);
addKeyListener(this);
setVisible(true);
}
public void keyPressed(KeyEvent ke){
if(ke.isAltDown() && ke.getKeyCode()==KeyEvent.VK_R){
new JOptionPane().showMessageDialog(this, "You pressed Alt-R");
}
}
public void keyReleased(KeyEvent ke){}
public void keyTyped(KeyEvent ke){}
public static void main(String[] args){
new YQuestions();
}
}
I took this from yahoo answers