By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,448 Members | 1,236 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,448 IT Pros & Developers. It's quick & easy.

Key handler problem

P: n/a
I'm got a little problem that I can't figure out. I have a UserControl and
I'm trying to detect the Shift key. I'm using KeyUp and KeyDown event
handlers to set a flag when the Shift key is pressed. My problem is that the
handlers aren't getting called. I have the handlers registered with the
control and I don't know what else to try. Anybody got an idea what the
problem might be?
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If your UserControl has any child controls, they could be the ones getting the
KeyDown/KeyUp events rather than the UserControl itself. This can happen if any
of the child controls gets the focus.

If that is the case, you can hook the KeyDown/KeyUp of all child controls
recursively to detect when the Shift key is pressed in any of them.

Hope this helps

--
Rodger

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence diagrams.

Chuck Bowling wrote:
I'm got a little problem that I can't figure out. I have a UserControl and
I'm trying to detect the Shift key. I'm using KeyUp and KeyDown event
handlers to set a flag when the Shift key is pressed. My problem is that the
handlers aren't getting called. I have the handlers registered with the
control and I don't know what else to try. Anybody got an idea what the
problem might be?

Nov 16 '05 #2

P: n/a
Thanks Rodger, I'll give it a try.

"Rodger Constandse" <ro*************@effexis.com> wrote in message
news:J%*******************@twister.socal.rr.com...
If your UserControl has any child controls, they could be the ones getting
the KeyDown/KeyUp events rather than the UserControl itself. This can
happen if any of the child controls gets the focus.

If that is the case, you can hook the KeyDown/KeyUp of all child controls
recursively to detect when the Shift key is pressed in any of them.

Hope this helps

--
Rodger

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence
diagrams.

Chuck Bowling wrote:
I'm got a little problem that I can't figure out. I have a UserControl
and I'm trying to detect the Shift key. I'm using KeyUp and KeyDown event
handlers to set a flag when the Shift key is pressed. My problem is that
the handlers aren't getting called. I have the handlers registered with
the control and I don't know what else to try. Anybody got an idea what
the problem might be?


Nov 16 '05 #3

P: n/a
Small FYI, it turns out that all you have to do to detect the Shift key in
an event handler is to use the Control.ModifierKeys property...

"Rodger Constandse" <ro*************@effexis.com> wrote in message
news:J%*******************@twister.socal.rr.com...
If your UserControl has any child controls, they could be the ones getting
the KeyDown/KeyUp events rather than the UserControl itself. This can
happen if any of the child controls gets the focus.

If that is the case, you can hook the KeyDown/KeyUp of all child controls
recursively to detect when the Shift key is pressed in any of them.

Hope this helps

--
Rodger

<http://www.SequenceDiagramEditor.com>
Sequence Diagram Editor - A quick and easy way to draw and edit sequence
diagrams.

Chuck Bowling wrote:
I'm got a little problem that I can't figure out. I have a UserControl
and I'm trying to detect the Shift key. I'm using KeyUp and KeyDown event
handlers to set a flag when the Shift key is pressed. My problem is that
the handlers aren't getting called. I have the handlers registered with
the control and I don't know what else to try. Anybody got an idea what
the problem might be?


Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.