This article is from the Mac Programming FAQ, by Jon Watte email@example.com with numerous contributions by others.
Just call EventAvail and check the event.modifiers field.
Only works when you are in the foreground. You can also use
GetKeys(), or (as a last resort) check the lo-mem global KeyMap