keyevent

A Java KeyStroke, KeyEvent, Action, InputMap, and ActionMap example

I don't know if this is the "proper" way to handle having multiple keystrokes for one action, but until I find a better approach I thought I'd share this here.

For my Java text editor application, on Mac OS X I want the user to be able to use any of the following keystrokes to increase the font size by one unit:

  • [Apple][=]
  • [Apple][Shift][=]
  • [Apple][+]

Each of those keystrokes might be interpreted by a user as being equivalent to [Apple][+], so I want to be sure I support all three of them.

Mac Java keystroke - How to handle the Apple (command) key with Java on Mac OS X

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

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). On Windows systems I used to write key-binding code like this:

Syndicate content