I'm having problems getting my KeyDown code to run exactly the way I want in D2005. For example in my Main Form's OnKeyDown I have the following:
if Key = VK_SHIFT then Shifted := True; if Key = VK_ESCAPE then begin If position = something then do something end; if Key = VK_ADD then AddActExecute(Self); if Key = VK_SUBTRACT then DeleteActExecute(Self); As you can see I'm implementing not only direct key down procedures but also setting a Boolean var so that when clicking a button object while holding the Shift key down the called procedure will branch a particular way. In my Dorm's OnKeyUp I reverse the value of this same Boolean var so that the next time this same button is clicked without the shift key being pressed down, the procedure will branch differently The problem is that the OnKeyUp procedure is not working to reverse the Boolean value when it is let back up from the KeyDown procedure that first sets it! I have to click the shift key a number of times in quick succession or the next time I click the button that runs my branched action it will run as if the shift key is still depressed! And I've tried this with a number of different keyboards and get the same results! Then someone suggested I over-ride the IsShortcut private function and I tried that as shown here: function TMainF1.IsShortCut(var Message: TWMKey): Boolean; Var sc:TShortCut; begin sc:=ShortCut(Message.CharCode, KeyDataToShiftState(Message.KeyData)); if sc=ShortCut(VK_SHIFT,[]) then begin Shifted := True end else begin if sc=ShortCut(VK_ESCAPE,[]) then begin If position = something then do something end else begin if sc=ShortCut(VK_ADD,[]) then begin AddActExecute(Self) end Else begin if sc=ShortCut(VK_SUBTRACT,[]) then begin DeleteActExecute(Self); end Else begin result:=inherited IsShortCut(Message); end; end; end; end end; This works fine when ONLY a key is required to run a procedure or function but NOT when I need to set a var to work in combo with a mouse-click on a button. It seems to me that when certain keys are used such as a shift or Ctrl Key they must be listed in the second parameter like so: ssShift or ssCtrl, but if this is true, what would I place in the first parameter? Also, it seems that when I over-ride the Form's IsShortcut as I did above, the OnKeyDown code Ihad set up for individual edits also stopped working, so they too must be being over-ridden by the form code! And I need distinct procedures to run when I click a shortcut key while these edits have focus! Is there a better way to solve these problems? In most cases every form is using straight shortcuts based on the escape and return keys, and the F1 key, to run my Modalresults and Application.Helpcontext() code...while individual edits have their own OnKeyDown code while selected using the same Return and escape keys...and in some I also am using various Shift, Menu, and/or Ctrl keys in combination with a button click so I need the solution to work for both. Also, if anyone knows or has a list of Windows default shortcut keys, especially those used for database control, like F2 for Edit, and F5 for Post, I would appreciate a copy of the list. I've been trying to find one unsuccessfully for awhile. from: Robert Meek at: [EMAIL PROTECTED] dba "Tangentals Design" home of "PoBoy" freeware Windows apps and utilities located at: www.TangentalsDesign.com e-mail to: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] _______________________________________________ Delphi mailing list -> Delphi@elists.org http://www.elists.org/mailman/listinfo/delphi