I want to detect whether the SHIFT key is held down when a button is pressed.
Here is what I am doing:

JButton butt = new JButton("Click me!");

butt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
if ( (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0)
JOptionPane.showMessageDialog(null, "SHIFT key is pressed.");
JOptionPane.showMessageDialog(null, "SHIFT key is not pressed.");

While testing this code, what I find out is that e.getModifiers() always
returns 0 and hence the message "SHIFT key is not pressed." is always displayed.

How do I enable the tracking of keys such as SHIFT, CNTRL or ALT ?

Any help is appreciated.