473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

KeyDown not capturing all keys

I have a control that handles the KeyDown event but it does not seem to
execute when a combination of keys is pressed - like CTRL+Z. If I
press CTRL, it executes. If I press Z, it executes. But the handler
does not see the combination.

Now this control is contained within another control which is contained
within another. The top most control does see the CTRL+Z. I can easily
pass down the key info, but why does the nested control see some keys
events and not others? It would be cleaner if the nested control simply
handled all input.

Thanks,
Mike

Sep 18 '06 #1
3 5228
KeyDown Event does not handle all keys.

I quote the remark from MSDN help for the KeyDown Event located at:
http://msdn2.microsoft.com/en-us/lib...l.keydown.aspx
----------------------------------------------------------
Key events occur in the following order:

KeyDown

KeyPress

KeyUp

To handle keyboard events only at the form level and not enable other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true. Certain
keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled by
controls automatically. To have these keys raise the KeyDown event, you
must override the IsInputKey method in each control on your form. The
code for the override of the IsInputKey would need to determine if one
of the special keys is pressed and return a value of true.

For more information about handling events, see Consuming Events.
-----------------------------------------------------------------------

ML****@hotmail.com wrote:
I have a control that handles the KeyDown event but it does not seem to
execute when a combination of keys is pressed - like CTRL+Z. If I
press CTRL, it executes. If I press Z, it executes. But the handler
does not see the combination.

Now this control is contained within another control which is contained
within another. The top most control does see the CTRL+Z. I can easily
pass down the key info, but why does the nested control see some keys
events and not others? It would be cleaner if the nested control simply
handled all input.

Thanks,
Mike
Sep 18 '06 #2
Thanks for the reply, but this does not seem to apply to my situation.

1) Handling events at the form level...
I am not creating a windows form. It's a control used by other
developers. Also, I am trying to get the opposite effect.

2) Override the IsInputKey function...
This function only works on individual keys. As I stated, the
individual keys are fine. My control is not seeing the combination.

Any other ideas?

DaanishRumani wrote:
KeyDown Event does not handle all keys.

I quote the remark from MSDN help for the KeyDown Event located at:
http://msdn2.microsoft.com/en-us/lib...l.keydown.aspx
----------------------------------------------------------
Key events occur in the following order:

KeyDown

KeyPress

KeyUp

To handle keyboard events only at the form level and not enable other
controls to receive keyboard events, set the KeyPressEventArgs.Handled
property in your form's KeyPress event-handling method to true. Certain
keys, such as the TAB, RETURN, ESCAPE, and arrow keys are handled by
controls automatically. To have these keys raise the KeyDown event, you
must override the IsInputKey method in each control on your form. The
code for the override of the IsInputKey would need to determine if one
of the special keys is pressed and return a value of true.

For more information about handling events, see Consuming Events.
-----------------------------------------------------------------------

ML****@hotmail.com wrote:
I have a control that handles the KeyDown event but it does not seem to
execute when a combination of keys is pressed - like CTRL+Z. If I
press CTRL, it executes. If I press Z, it executes. But the handler
does not see the combination.

Now this control is contained within another control which is contained
within another. The top most control does see the CTRL+Z. I can easily
pass down the key info, but why does the nested control see some keys
events and not others? It would be cleaner if the nested control simply
handled all input.

Thanks,
Mike
Sep 18 '06 #3
I found that the control works fine when it is used within a C#
application. The problem occurs when it is used within a C++
application. It seems that simple keys like "Z" are routed to the
sub-control that has focus while the "CTRL+Z" key strokes are routed to
the topmost control. Strange...

ML****@hotmail.com wrote:
I have a control that handles the KeyDown event but it does not seem to
execute when a combination of keys is pressed - like CTRL+Z. If I
press CTRL, it executes. If I press Z, it executes. But the handler
does not see the combination.

Now this control is contained within another control which is contained
within another. The top most control does see the CTRL+Z. I can easily
pass down the key info, but why does the nested control see some keys
events and not others? It would be cleaner if the nested control simply
handled all input.

Thanks,
Mike
Sep 19 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: SpinningCone | last post by:
Im currently building a MUD telnet client in VB .NET and am having trouble mapping functionality to certain keys. the user is focused on a command textbox and can enter text and send it etc etc...
3
by: Greg | last post by:
I want to be able to capture the user pressing Ctrl+S. I know that the IE browser has a key binding for Ctrl+S but is there any way that I can be notified of this key press anyway. I have found...
2
by: JPSutor | last post by:
I need to capture multiple keys with the keyUp event (Ex. Tab + 7) I can captuee individual keys by I'm not sure how to caputre multiple keys
2
by: Phil Galey | last post by:
I have a Panel control docked on all sides on a form and the panel control contains a PictureBox. I'm using the KeyDown event of the form to respond to the and keys for resizing the image and the...
2
by: Phil Galey | last post by:
I'm using the ProcessCmdKey event to capture various keys that are pressed. However, I'm having trouble capturing the combination of the CTRL key and, say, the DOWN key. If I just press the CTRL...
1
by: tmarkovski | last post by:
Hello, I found this little code which basicly writes any keystroke to the app window, however, it only works for the app window. I wanted to modify it to work when any window is focused, just...
2
by: senfo | last post by:
Hello all, To help alleviate human error, I'm developing an application that uses a barcode reader to fill in a value in a TextBox control. The barcode reader is connected to the PC through the...
2
by: Mohammad Omer Nasir | last post by:
Hi, I am working on vs2k5 IDE for C# development. I made one Form which has one button on it. I tried to override KeyDown message on From but KeyDown message received. if Form does not...
2
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
I have a tabcontrol where I want to capture the CTRL+C key combination. My tabcontrol has on its tabpages some treeView controls. My intention is to intercept the event of pressing the CTRL+C when...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.