Apple "Command" key symbol

Started by mot, August 21, 2006, 01:35:00

Previous topic - Next topic

mot

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

Spezi

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
Ich bin, ich weiß nicht wer.
Ich komme, ich weiß nicht woher.
Ich gehe, ich weiß nicht wohin.
Mich wundert, dass ich so fröhlich bin.

mot

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?

Spezi

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) {}
}
Ich bin, ich weiß nicht wer.
Ich komme, ich weiß nicht woher.
Ich gehe, ich weiß nicht wohin.
Mich wundert, dass ich so fröhlich bin.