Keydown Acction with Shift+F9

Hi All,
I am trying to use a Xkeys usb keypad in an mac OS app (also soon ported to windows). I have everything working in a test mode, with the exception of capturing the down event on a couple of special keys.

My working keys are:
If Keyboard.AsyncKeyDown(&h65) then //F9
StaticText1.text=“F9 key was pressed”
end if
and that works great.

but I also have keys that are programmed with Shift+F9, Shift+F10, Shift+F11, how do I ‘capture’ these actions? I look at a couple hex keyboard maps but did not see anything for the shift key.

THX
JMW

BooleanValue = aKeyboard.AsyncCommandKey
BooleanValue = aKeyboard.AsyncControlKey
BooleanValue = aKeyboard.AsyncShiftKey

so something like

If Keyboard.AsyncKeyDown(&h65) then //F9
 if Keyboard.AsyncShiftKey then 
 StaticText1.text="SHIFT F9 key was pressed"
else 
StaticText1.text="F9 key was pressed"
end if
end if

and please use the CODE tags, it makes it much easier to separate chat from code snippets

You don’t say whether your code is in a keydown event, but if it is, don’t use async methods.

Hi Dave,
Thank you, your process is much cleaner the the two steps i ended up using. I did upgrade my to use your process.

CODE tags, I applogize, I need to read the forum rules on how to do correctly.

Tim, I am using the a KeyDown event and in another pot I saw it was suggested the Asycn version was the better way to. I am monitoring for 8 function keys altogether and then respnding differently baded on which function key was pressed.

I have run into a snagg though, if the user holds down the F9 key the F9 continues to get sent repeatedly, even with repeat keys turned off on the mac. I am thinking of going to geting the keyup event instead.

Thx
JMW

Either you misunderstood, or the advice in the other post was just wrong. In the KeyDown event, use the non-async versions of the Keyboard methods. If you want to monitor the keyboard regardless of which control has focus, then use the Async versions in a Timer. Don’t mix the two.

Dave, as I said this worked well.

[quote=313661:@Dave S]BooleanValue = aKeyboard.AsyncCommandKey
BooleanValue = aKeyboard.AsyncControlKey
BooleanValue = aKeyboard.AsyncShiftKey

so something like

If Keyboard.AsyncKeyDown(&h65) then //F9
 if Keyboard.AsyncShiftKey then 
 StaticText1.text="SHIFT F9 key was pressed"
else 
StaticText1.text="F9 key was pressed"
end if
end if

and please use the CODE tags, it makes it much easier to separate chat from code snippets[/quote]

Here is what ended up with (code not cleaned and simplified yet). I just need to figure out how best to deal with a user holding down a function key which sends the function many times over. My app has 8 buttons that run 8 different channels of two media servers and one ‘All Stop’ button, each server with their own ip address. The users use Xkeys external keypad to run the systems"s main software for programming. The main app will only talk to one server at a time, my app sends the the play commands to both servers at the same time for a primary & back up, or each separately. I will try and get a picture link up.

[code] Dim Shift as Boolean

	Shift=False
	
	If Keyboard.AsyncShiftKey then
			Shift=True
	else
			Shift= False
	end if
	
	
	If Keyboard.AsyncKeyDown(&h65) then //F9 launches player 1, Shift+F9 Launches player 5
			'if Keyboard.AsyncShiftKey then
			If Shift then
					Player = "5"
					SendGo
					StaticText1.text="SHIFT+F9 key was pressed"
			else 
					Player = "1"
					SendGo
					StaticText1.text="F9 key was pressed"
			end if
	end if
	
	If Keyboard.AsyncKeyDown(&h6D) then //F10 launches player 2, Shift+F10 launches player 6
			'if Keyboard.AsyncShiftKey then
			If Shift then
					Player = "6"
					SendGo
					StaticText1.text="SHIFT+F10 key was pressed"
			else 
					Player = "2"
					SendGo
					StaticText1.text="F10 key was pressed"
			end if
	end if
	
	If Keyboard.AsyncKeyDown(&h67) then //F11 launches player 3, Sift+F11 launches player 7
			'if Keyboard.AsyncShiftKey then
			If Shift then
					Player = "7"
					SendGo
					StaticText1.text="SHIFT+F11 key was pressed"
			else 
					Player = "3"
					SendGo
					StaticText1.text="F11 key was pressed"
			end if
	end if
	
	If Keyboard.AsyncKeyDown(&h6F) then //F12 launches player 4, Shift+f12 launches player 8
			'if Keyboard.AsyncShiftKey then
			If Shift then
					Player = "8"
					SendGo
					StaticText1.text="SHIFT+F12 key was pressed"
			else 
					Player = "4"
					SendGo
					StaticText1.text="F12 key was pressed"
			end if
	end if
	[/code]

Here is the screen shot from my app with he Function keys…