
So, my first option will show you how to insert this sign in Word using a keyboard shortcut.īelow are two easy ways you can type the em dash in word However, below are the step by step break down on how to type it. Type the em dash sign into your Word document. The table above contains all the information you need to As you can see, a minor change to your approach makes your Java/Swing application look and feel just like a native Mac application.The table below also gives you the em dash shortcuts and alt code for Windows and Mac. I hope this short tutorial on handling the Mac Command key when writing Java/Swing KeyStroke code has been helpful.

Mac Java keystrokes - Handling the Command key (Sorry, those images are a little blurry.) I can see from the following image that OS X is now ready to work with the Apple/command key: So, when I switch to this second (corrected) version of my Mac Java KeyStroke code: If you're a Mac user, you know that's not correct for the Mac look and feel.

I see that OS X is expecting me to use the Control key: First, when I use this older line of Java code: KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()) Īs a quick look at what this change to Mac Java KeyStroke handling does, here are two images of my Mac menubar that demonstrate the difference from changing this single line of Java code. KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK) īut once I started doing more Java Swing programming on Mac OS X, I realized I needed to change that line of code to look like this: On Windows systems I used to write key-binding code like this: When I switched from "Java programming on Windows" (or Linux) to "Java programming on a Mac", I quickly learned that I was going to have to change the way I bound my keystrokes for handling key-driven events (things like keystroke-driven popup menus, mnemonics, or accelerator keys).

Java Mac keystroke FAQ: How do I write Java KeyStroke code for Mac OS X systems?
