473,405 Members | 2,344 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,405 software developers and data experts.

Capturing cursor keys ??

Hi

I have a usercontrol , the keypress and keyup/down events do not seem to
work on the cursor keys .
How can i capture the cursor keys when my control has the focus ?

Johan

Aug 21 '06 #1
2 2604
Sagaert,

Some of the keys are considered sepcial and are processed by the control.
Arrow keys (I guess this is what are you reffering to as cursor keys) are
among them.

In order to stop the control to thread these keys specially and to fire the
ususal events for them you need to override IsInputKey method. Here is an
example how to "unlock" the events for arrow keys:

In the user control add the following method:
protected override bool IsInputKey(Keys keyData)
{
if (keyData == Keys.Left || keyData == Keys.Right || keyData == Keys.Up
|| keyData == Keys.Down)
{
return true;
}
return base.IsInputKey(keyData);
}

Now the control will fire KeyUp/Down for arrow keys.
--
HTH
Stoitcho Goutsev (100)

"Sagaert Johan" <RE*************@hotmail.comwrote in message
news:ui**************@TK2MSFTNGP06.phx.gbl...
Hi

I have a usercontrol , the keypress and keyup/down events do not seem to
work on the cursor keys .
How can i capture the cursor keys when my control has the focus ?

Johan

Aug 21 '06 #2
Many Thanks

"Stoitcho Goutsev (100)" <10*@100.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Sagaert,

Some of the keys are considered sepcial and are processed by the control.
Arrow keys (I guess this is what are you reffering to as cursor keys) are
among them.

In order to stop the control to thread these keys specially and to fire
the
ususal events for them you need to override IsInputKey method. Here is an
example how to "unlock" the events for arrow keys:

In the user control add the following method:
protected override bool IsInputKey(Keys keyData)
{
if (keyData == Keys.Left || keyData == Keys.Right || keyData == Keys.Up
|| keyData == Keys.Down)
{
return true;
}
return base.IsInputKey(keyData);
}

Now the control will fire KeyUp/Down for arrow keys.
--
HTH
Stoitcho Goutsev (100)

"Sagaert Johan" <RE*************@hotmail.comwrote in message
news:ui**************@TK2MSFTNGP06.phx.gbl...
Hi

I have a usercontrol , the keypress and keyup/down events do not seem
to
work on the cursor keys .
How can i capture the cursor keys when my control has the focus ?

Johan



Aug 21 '06 #3

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

Similar topics

3
by: inevercheckthisaddress | last post by:
I'm writing some stuff where I wish to allow the cursor keys to control elements in a page. This has not been a problem except with Safari which appears to duplicate the keydown and keyup events...
7
by: Seash | last post by:
Hi friends , here is the sample code private void txtbox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { if(e.KeyChar == 13) //enter { txtbox2.Focus(); }
0
by: veena | last post by:
hello, i have got a problem of how to capture two keys when pressed together i.e in my task i require certain action to be performed when the ctrl and 'A' keys are pressed together i.e i need to...
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...
3
by: MLM450 | last post by:
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...
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: =?Utf-8?B?TWFyaw==?= | last post by:
Does anyone know where there is some sample code that explains now a user; using the mouse can click on an image on the screen. Capture the image by boxing it in using the mouse and then save it to...
5
by: cantrell78 | last post by:
I'm dynamically building a list of divs that a user can click and sets off an action. I was hoping to build into it a way to use the up and down arrow keys to navigate the list and the enter key to...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.