Intercepting Keypress 
Author Message
 Intercepting Keypress

I want to intercept a keypress for a specific control on my form, i.e.
be able to detect the key, but not to have the key value passed along
to the control.

In this case I want to intercept the + and - keys on a date control to
advance and move the date back, as in MS Money.

I know how to create a Key_Up event and test for the keys I want to
intercept. I will then programmatically increase or decrease the date
currently displayed and update the value of the control.

How do I keep the keys that I want to intercept from getting to the
control and changing the data?

E.g.  Control box reads: 12/06/00  
User Presses +
The program changes the value to 12/07/00 without it becoming "+"

TIA

Keith



Sun, 25 May 2003 03:00:00 GMT  
 Intercepting Keypress
You can do this with the line:

KeyCode = 0

after you have tested it.

BTW, you are better to use the KeyDown event, as then you get autorepeat.
I've just pinched your idea and tried the above and it works very well. :-)

--
--
Rob McClean
"...a Saviour has been born to you in David's city, who is Christ the Lord."
The Holy Bible, Luke ch 2 v 11

Quote:
> I want to intercept a keypress for a specific control on my form, i.e.
> be able to detect the key, but not to have the key value passed along
> to the control.

> In this case I want to intercept the + and - keys on a date control to
> advance and move the date back, as in MS Money.

> I know how to create a Key_Up event and test for the keys I want to
> intercept. I will then programmatically increase or decrease the date
> currently displayed and update the value of the control.

> How do I keep the keys that I want to intercept from getting to the
> control and changing the data?

> E.g.  Control box reads: 12/06/00
> User Presses +
> The program changes the value to 12/07/00 without it becoming "+"

> TIA

> Keith



Sun, 25 May 2003 03:00:00 GMT  
 Intercepting Keypress
Erm, KeyPress will give autorepeat not keydown.


Quote:
> You can do this with the line:

> KeyCode = 0

> after you have tested it.

> BTW, you are better to use the KeyDown event, as then you get autorepeat.
> I've just pinched your idea and tried the above and it works very well.
:-)

> --
> --
> Rob McClean
> "...a Saviour has been born to you in David's city, who is Christ the
Lord."
> The Holy Bible, Luke ch 2 v 11


> > I want to intercept a keypress for a specific control on my form, i.e.
> > be able to detect the key, but not to have the key value passed along
> > to the control.

> > In this case I want to intercept the + and - keys on a date control to
> > advance and move the date back, as in MS Money.

> > I know how to create a Key_Up event and test for the keys I want to
> > intercept. I will then programmatically increase or decrease the date
> > currently displayed and update the value of the control.

> > How do I keep the keys that I want to intercept from getting to the
> > control and changing the data?

> > E.g.  Control box reads: 12/06/00
> > User Presses +
> > The program changes the value to 12/07/00 without it becoming "+"

> > TIA

> > Keith



Tue, 27 May 2003 22:31:58 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Can VBA intercept keypress within Excel ?

2. Intercepting keypresses

3. intercept keypress?

4. Assing single keys to macros // intercept keypresses

5. Intercepting Close event through AutoClose macro ( also intercepting FilePrint and FileSave)

6. In vbs exist the keypress event

7. Keypress event

8. Disabling shift keypress that prevents code execution

9. Keypress Counter

10. Capture keypress


 
Powered by phpBB® Forum Software © phpBB Group