LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: mot on August 21, 2006, 01:35:00

Title: Apple "Command" key symbol
Post by: mot on August 21, 2006, 01:35:00
I'm preparing to do a Mac port (before actually getting a Mac) and I've been advised that Command-Q absolutely should quit the game.

What is the LWJGL Keyboard.KEY_... symbol for the Apple "command" key?

Thanks in advance for any suggestions.
Tom
Title: Command+Q
Post by: Spezi on August 21, 2006, 11:20:15
I'd say that Command+Q is like Alt+F4 in Windows and therefore automatically sends a close message. But that's just an assumption :D
Title: Apple "Command" key symbol
Post by: mot on October 12, 2006, 22:36:40
That's right, I tried this on a borrowed Mac and I got the close message after pressing Command+Q.

So I returned the Mac and forgot that I would eventually need to read copy/paste commands as well. On Macs, paste is Command+V, right?

Is the Command key equal to KEY_LWIN/KEY_RWIN?
Title: Apple "Command" key symbol
Post by: Spezi on October 16, 2006, 08:16:58
Quote from: "mot"On Macs, paste is Command+V, right?
Right.
Quote from: "mot"Is the Command key equal to KEY_LWIN/KEY_RWIN?
The Windows keys are VK_WINDOWS and VK_CONTEXT_MENU.
The command key for Mac is VK_META.
If there is KeyEvent e you can use e.getKeyLocation() to check if it was KEY_LOCATION_LEFT or KEY_LOCATION_RIGHT

Some simple test program for getting the keycodes:
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;

@SuppressWarnings("serial")
public class KeyboardTest extends JFrame implements KeyListener {

public KeyboardTest() {
setVisible(true);
addKeyListener(this);
new Thread() {
public void run() {
for (;;) {
try {
sleep(50);
} catch (InterruptedException e) {
break;
}
}
}
}.start();
}

public static void main(String[] args) {
new KeyboardTest();
}

public void keyPressed(KeyEvent e) {
System.out.println(e);
}

public void keyReleased(KeyEvent e) {}
public void keyTyped(KeyEvent e) {}
}