Re: Detecting a keydown or key up.
Re: Detecting a keydown or key up.
- Subject: Re: Detecting a keydown or key up.
- From: "Zavatone, Alex" <email@hidden>
- Date: Tue, 02 Aug 2011 13:09:59 -0700
- Acceptlanguage: en-US
- Thread-topic: Detecting a keydown or key up.
That's perfect Stan.
I remember back in the days of Director and Shockwave when I made my own modifier key event generators for up and down. Maybe one of these days I'll get off my butt and do the same for AS.
Thanks.
On Aug 2, 2011, at 3:03 PM, Stan Cleveland wrote:
> On Aug 2, 2011, at 8:25 AM, Zavatone, Alex wrote:
>
>> I've been looking around with google and wonder if, in this modern age, we still have to monkey around to detect a key's state? Particularly the modifier keys?
>
> Hi Alex,
>
> Here's another option, if you don't mind the overhead of a shell call. The checkModifierKeys shell command by Stefan Klieme can be downloaded from http://www.klieme.ch/pub/checkModifierKeys.zip. You can install it anywhere, if you include its full POSIX path in your 'do shell script' command (as shown below). Or, if you put it within one of the paths from the shell's $PATH environment variable* (if you grok that), you can just use 'checkModifierKeys'.
>
> Here's a sample of usage:
>
> set modKeyDown to modifierKeyDownTest("option")
> --> true
>
> on modifierKeyDownTest(theKey)
> set utilityPath to "/usr/local/bin/checkModifierKeys" -- note use of full path
> set modKeyDown to do shell script (utilityPath & " " & theKey)
> return (modKeyDown as integer) as boolean
> end modifierKeyDownTest
>
> It only checks for modifier keys. Besides "option", you can test for "shift", "cmd", "control", and "capslock" or combinations thereof. For example:
>
> set modKeyDown to modifierKeyDownTest("cmd option")
>
> The above line will return 'true' if both keys are held down and 'false' if one or neither is held down.
>
> It might not be what you're looking for, but thought I'd mention it anyway.
>
> Stan C.
> _______
> *To set up the 'do shell script' environment variable, you would create a created property list file at /Users/you/.MacOSX/environment.plist and define a PATH child property with a value of something like "/opt/local/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin".
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
This email message and any attachments are for the sole use of the intended recipient(s) and may contain information that is proprietary to U.S. Foodservice, Inc and/or its subsidiaries or otherwise confidential or legally privileged. If you have received this message in error, please notify the sender by reply, and delete all copies of this message and any attachments. If you are the intended recipient you may use the information contained in this message and any files attached to this message only as authorized by U.S. Foodservice. Files attached to this message may only be transmitted using secure systems and appropriate means of encryption, and must be secured using the same level password and security protection with which the file was provided to you. Any unauthorized use, dissemination or disclosure of this message or it's attachments is strictly prohibited.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden