1

I was wondering if there was a KeyEvent code for the Mac "Option" key within the java.awt.event.KeyEvent library. I'm trying to write a class for executing Mac OS specific shortcuts (i.e. SHIFT + OPTION + COMMAND + ESC), but I can't find the code for the Option key anywhere. Any help is appreciated!

John Smith
  • 13
  • 4
  • 2
    Did you try logging the key event that happens when you do press Option? when you log it, it's just a matter of finding out which KeyEvent code from the Robot class is identical to it. – Shark Jul 06 '18 at 16:45
  • Wow, thanks for the super fast reply! I'll go try that right now and see if it comes up. – John Smith Jul 06 '18 at 16:48

1 Answers1

2

Try logging it to find out it's keyCode and find the key with the same keycode as what you logged. In case logging doesn't help you out, try using ALT.

From what I know, for all intents and purposes, Mac's option is usually the equivallent of ALT on Windows, and will probably end up resolving as VK_ALT

EDIT: Upon further inspection, it seems that Option uses keycode 58 (http://macbiblioblog.blogspot.com/2014/12/key-codes-for-function-and-special-keys.html) and it seems you're out of luck, since the awt.event.KeyEvent doesn't cover that one...

Shark
  • 6,513
  • 3
  • 28
  • 50
  • Relevant reading: https://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes – Shark Jul 06 '18 at 17:04
  • 1
    I ended up finding/creating an alternate shortcut to circumvent the use of "Option", but thank you so much for all your help. I really appreciate your hard work! – John Smith Jul 06 '18 at 20:31