473,378 Members | 1,456 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,378 software developers and data experts.

Key handler problem

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
3 1712
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. ...
2
by: Steve Richfield | last post by:
My error handler works GREAT. However, VBA seems to have some bugs/features that are causing it fits. The little snippet that I put at the end of each routine looks like this: Error_Handler: If...
10
by: Wylbur via DotNetMonster.com | last post by:
Hello to all of you geniuses, I'm having a problem trying to get an Init handler to fire for a Placeholder control at the initialization phase. I’ve posted this problem to 3 other ASP.NET...
10
by: Sean Dockery | last post by:
I have the following HTML file that I've been using for testing... <html> <head> <script type="text/javascript"> <!-- function handleWindowLoad() { var items = ; for (var i = 0; i < 11; i++)...
10
by: robert d via AccessMonster.com | last post by:
I have a global error handler that up until today has been working flawlessly. Let me first provide the relevant code **************************************************************** On Error...
3
by: usenet | last post by:
Hi all, I've created a custom session handler that saves session data to a MySQL database. If the database server is down, I'd like to fallback to PHP's default session handler (files) until the...
6
by: Joseph Geretz | last post by:
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to use VSTO. I've gotten this to the point where my VSTO Addin installs its Menu items and Toolbar buttons when Outlook...
6
by: =?Utf-8?B?cHJhZGVlcF9UUA==?= | last post by:
I am trying to create a simple HTTP handler in ASP.net 2.0. I am using VS 2005. I am trying to handle a custom extension file givein in the URL. I have also created the following entry in the...
16
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not...
13
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
This is a follow-up to my post "Silverlight video doesn't work when file is streamed from handler in ASP.net" at...
1
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: 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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.