>>>I've been trying to find a sample if a form's .KeyPress event in action without success.
>>>
>>>What I'm trying to do is allow my base form class top process next previous etc by using the keyboard as well as using the toolbar. I've got it working well, except that the key values seem to be duplicated with other key's values. There must be a way. My code in the KeyPress event is...
>>>
>>>do case
>>> case nKeyCode = 19
>>> oToolbar.tbSearch.Click
>>> case nKeyCode = 2
>>> oToolBar.tbNext.Click
>>> case nKeyCode = 26
>>> oToolBar.tbPrev.Click
>>> case nKeyCode = 29
>>> oToolBar.tbFirst.Click
>>> case nKeyCode = 23
>>> oToolBar.tbLast.Click
>>>endcase
>>>
>>>
>>>Three questions.
>>>
>>>1.How do I determine that the Ctrl key is pressed so I don't process other keys (eg; 19 is Ctrl-s and Alt-r)
>>>
>>>2. How do I determine the difference between Ctrl-Right and Ctrl-b, both of which return a keycode of 2.
>>>
>>>3. How do I ensure that the keys I want to use are removed from the buffer and don't get passed to the control - and those that I don't want to use are passed to the control.
>>>
>>>The help and manuals are no help on this. There seems to also be no reference to this in UT's extensive knowledge base - ie; I'm dumb and can't see something everyone else takes as obvious :)
>>>
>>>Steve
>>
>>Hi Steve,
>>To determine which key combination in fact pressed there are two parameters in keypress (nKeyCode, nShiftAltCtrl).
>>nShiftAltCtrl, Shift=1, Ctrl=2, Alt=4. It is a combination value, ie: if both Ctrl+Alt is pressed then value is 6, Shift+Ctrl = 3, Shift+Alt = 5 and finally Shift+Alt+Ctrl = 7. nKeyCode give the inkey() value (scan code) of the pressed key combination.
>>Though, ALT combination
doesn't produce a "Keypress" event.
>>
>>1- nKeyCode = 19, then it's Ctrl+s (ALT combination
doesn't produce a "Keypress" event).
>>2- Unfortunately you cannot directly. You should also check if a value is added in interactivechange (Ctrl+b add, Ctrl+ra doesn't).
>>3- Keypress by default doesn't "absorb" the keypress. For keys you want to be processed in keypress event and then clear from buffer use "nodefault".
>>
>>*Keypress
>>if nKeyCode = 10
>> nodefault
>> ...
>>endif
>>
>>Cetin
>Hello Steve;
>Why not try the lastkey() function. This allows ctrl + and
>alt + values. Again, not the ctrl+alt+ values
>
>Sandy
Hi Sandy,
I'm afraid you're wrong about it. Lastkey() values are same as keypress codes (both inkey() values). Besides lastkey() doesn't fire as an event. To myself I obey the Jim Booth's suggestion (coordinate menus with toolbars and use Alt+combination).
Cetin