Mital Kakaiya [MCSD.NET]
In Programming, Logic is everything.

How to handle special key events?

Saturday, June 11, 2005 1:27 AM

Microsoft .NET Framework has KeyUp, KeyPress and KeyDown events. These events capture only limited character set. Also, Arrow keys do not fire KeyPress and KeyDown events, but it fires KeyUp event.

Now application needs to capture TAB/Arrow keys efectively, before any part of the application reads or fires any events. Also how to disable certain keys within an application?

To handle special key events at the form or control level, overrides protected ProcessCmdKey function as follow:

To handle special key events at an application level, implements IMessageFilter. This interface allows an application to capture a message before it is dispatched to a control or form:

Happy "Key" Coding :)


Feedback

# re: How to handle special key events?

This was amazing!! Thank you so much! 4/6/2006 4:40 PM | Denver Root

# re: How to handle special key events?

Thank your very much for the code... 10/19/2006 5:24 PM | EVS Ram

# re: How to handle special key events?

send me a sample of letter of salary increment because i worked for a year and the forex in the Philippines in terms of dollar-peso weaken and i want to save for my family back home 9/29/2007 5:00 AM | jopz

# re: How to handle special key events?

please be cind enugh to send me this 12/3/2008 6:31 AM | bandara

Post a comment





 

Please add 1 and 3 and type the answer here: