I have a Dell Inspiron E1505 and as you can see in this image it has some buttons on the front for mute, play/pause, stop, volume control, etc. The mute and volume buttons actually affect the volume settings for the computer itself, but the others can also be used to control some other applications, such as Windows Media Player and even Pandora.
How can I write an application that responds to input from these buttons? I don't have a specific application in mind yet, so a solution in any language would be great.
I tried setting up a KeyListener in Java Swing, and looking at the events that get triggered:
JFrame frame = new JFrame();
frame.addKeyListener(new KeyListener() {
@Override public void keyPressed(KeyEvent e) {
System.out.println("pressed: " + e);
}
@Override public void keyReleased(KeyEvent e) {}
@Override public void keyTyped(KeyEvent e) {}
});
frame.setVisible(true);
The result, regardless of which button I press, is:
pressed: java.awt.event.KeyEvent[KEY_PRESSED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=Undefined keyChar,keyLocation=KEY_LOCATION_STANDARD] on frame0
so AFAIK there is no way to distinguish between the different buttons. Again, I would accept a solution in any language, since I don't have any specific application in mind yet.