keyDown or NSResponder

Trying to wrap my brain around how to implement a keyDown event in my app with no luck. I would like for a table to perform one action on an item when double clicked, or a different action when the option key is held down and double clicked.
TIA, Chris

You can use setDoubleAction: to specify a handler to be triggered on a double-click in a table. In the handler, use NSEvent’s modifierFlags method to check what modifier keys are down.

Oh OK that was pretty easy. But this is probably not the most elegant way.

property NSEvent : class "NSEvent"
set keyFlag to NSEvent's modifierFlags
if (keyFlag as integer) = 524288 then
	tell me to log "wow its the option key" --or do whatever
end if

a search on bitwise on the forum shows me 2 posts that say it doesn’t exist. So is this the best way to filter it? I have some Cocoa methods where it’s:

if([theEvent modifierFlags] & NSAlternateKeyMask && [theEvent modifierFlags] & NSCommandKeyMask)

but obviously ampersand in Applescript (concat) is not bitwise

You need to coerce the flags to integers and then add them together like so:

on doubleClick_(sender)
		if current application's NSEvent's modifierFlags() is equal to (current application's NSAlternateKeyMask as integer) + (current application's NSCommandKeyMask as integer) then
			log "Double clicked with  Command/Option(Alt) keys down"
			log "Double clicked"
		end if
	end doubleClick_


The trouble with that is that it will fail if another key, like caps lock, is also down.

This gets around that problem:

set keyFlag to (current application's NSEvent's modifierFlags) as integer
if ((keyFlag div (current application's NSAlternateKeyMask as integer)) mod 2) = 1 and ((keyFlag div (current application's NSCommandKeyMask as integer)) mod 2) = 1 then