Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using KeyPress() to insert misc. user defined text
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Using KeyPress() to insert misc. user defined text
Miscellaneous
Thread ID:
00172958
Message ID:
00172958
Views:
80
I'm trying to set up a form to respond to a keypress, like SHIFT+F2, to insert a string of text. The problem I'm running into is that either I'm not getting a response to the keys I choose or I get bad behavior because of "over mapping"...SHIFT+F2 and SHIFT+U seem to have the same KeyCode.

I tried SHIFT+CNTRL+F2, but it doesn't respond...same thing with numerous other combinations.
LPARAMETERS nKeyCode, nShiftAltCtrl
* put this in the keypress of the edit region
* RML 12/30/98 - Of all the Stupid things!
* Shift+F2, Shift+F3, Shift+F4, Shift+F5, Shift+F6, Shift+F7
* 85        86        87        88        89        90
* are the same key codes as 
* Shift+U,  Shift+V,  Shift+W,  Shift+X,  Shift+Y,  Shift+Z
* see chart in help for INKEY()
LOCAL nSelect
nSelect = SELECT()
SELECT vExpandText
DO CASE
	CASE nKeyCode = 31 and nShiftAltCtrl = 2
		* ALT+S
		* call up the spell checker
		DO FS_CALL
		
	CASE nKeyCode = 85 and nShiftAltCtrl = 1
		* SHIFT+F2
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F2"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 85 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F2
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F2"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 86 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F3
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F3"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 87 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F4
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F4"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 88 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F5
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F5"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 89 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F6
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F6"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 90 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F7
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F7"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 91 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F8
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F8"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 92 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F9
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F9"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 93 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F10
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F10"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 135 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F11
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F11"
		KEYBOARD ALLTRIM(phrase)+" "
	
	CASE nKeyCode = 136 and nShiftAltCtrl = 5
		* SHIFT+CTRL+F12
		LOCATE FOR ALLTRIM(KeyLabel) = "SC+F12"
		KEYBOARD ALLTRIM(phrase)+" "
	
	OTHERWISE
ENDCASE
SELECT (nSelect)
Next
Reply
Map
View

Click here to load this message in the networking platform