Keystroke: Option Key Only

The problem I always have with this is that when you try to execute with a key command the functions don’t work because you are holding down other modifiers to make this do what you want. You have to either put in a delay or have the AppleScript check if modifiers are held down.

I use StefanK’s checkModifierKeys http://www.klieme.ch/pub/checkModifierKeys.zip

then add this code at the start of my AppleScript

try

   set modifierkeysPressed to true

   repeat while modifierkeysPressed
      set modifierkeysPressed to (do shell script "/Library/Scripts/checkModifierKeys") is not "0"
      delay 0.2
   end repeat
   
on error
   display dialog "You do not have 'checkModifierKeys' installed. "
end try

tell application "System Events"
   key code 58 -- Option Key
   
   -- key down option
   -- key up option
end tell

The key down and key up have cause problems many times for me where it a modifier can get stuck on because up doesn’t register. Those are good of course if you need to insert a delay or functions in between.

I use the above AppleScript for Sibelius with the control modifier and then jump to menu shortcuts because the control key pressed and released will show a bunch of other alpha keys I can press to run other functions. That way I can use any key command in Keyboard Maestro and have it run the right functions after I let go of all modifiers.

I am sure you have long solved your issue but might be helpful to someone else. Ideally I would rather have Keyboard Maestro just press and release a modifier while I am still holding that modifier to execute another command.