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

arrow keys and key down

ok - the problem - I made a simple breakout game out of a form, just
painting the background - and using keydown for left and right arrow keys to
control the bat - worked fine.

I then moved all the code into a user control, put it on the form. Now I
don't get keydown events when I press an arrow key - on either the form or
the usercontrol ?!!!?

I suspect somehow the container fucntionality has decided that they are was
of migrating between controls or something.
How do I stop it, and get my keys back?

Thanx,
Darren
Nov 15 '05 #1
2 8083
Darren,

User controls behave this way by default, to allow the arrow keys to be
used for moving the focus between controls.

To get the behaviour you need, add this method to the user control:

protected override bool IsInputKey(Keys keyData)
{
if (keyData == Keys.Down || keyData == Keys.Up ||
keyData == Keys.Left || keyData == Keys.Right)
{
return true;
}
else
{
return base.IsInputKey(keyData);
}
}
"Darren Oakey" <yo*@darrenoakey.info> wrote in message
news:Oi*************@TK2MSFTNGP10.phx.gbl...
ok - the problem - I made a simple breakout game out of a form, just
painting the background - and using keydown for left and right arrow keys to control the bat - worked fine.

I then moved all the code into a user control, put it on the form. Now I
don't get keydown events when I press an arrow key - on either the form or
the usercontrol ?!!!?

I suspect somehow the container fucntionality has decided that they are was of migrating between controls or something.
How do I stop it, and get my keys back?

Thanx,
Darren

Nov 15 '05 #2
thanx muchly, fixed the problem immediately!

"Magnus Krisell" <ma******@NOSPAMstudent.liu.se> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Darren,

User controls behave this way by default, to allow the arrow keys to be
used for moving the focus between controls.

To get the behaviour you need, add this method to the user control:

protected override bool IsInputKey(Keys keyData)
{
if (keyData == Keys.Down || keyData == Keys.Up ||
keyData == Keys.Left || keyData == Keys.Right)
{
return true;
}
else
{
return base.IsInputKey(keyData);
}
}
"Darren Oakey" <yo*@darrenoakey.info> wrote in message
news:Oi*************@TK2MSFTNGP10.phx.gbl...
ok - the problem - I made a simple breakout game out of a form, just
painting the background - and using keydown for left and right arrow keys
to
control the bat - worked fine.

I then moved all the code into a user control, put it on the form. Now

I don't get keydown events when I press an arrow key - on either the form or the usercontrol ?!!!?

I suspect somehow the container fucntionality has decided that they are

was
of migrating between controls or something.
How do I stop it, and get my keys back?

Thanx,
Darren


Nov 15 '05 #3

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

Similar topics

5
by: skipc | last post by:
Hi, I am stuck... I've got a popup window that displays a list in table format with links on the bottom to navigate the list <prev> 1 2 3 ... <next> When I demo'd to the users... they...
4
by: Neil Wallace | last post by:
Hi there, I have an application in which a grid of 100 or more buttons are put on a form in columns of 10. All the buttons are within a panel. They are added in runtime, and so they adopt a...
2
by: Vincent | last post by:
Hi, I have a user control that needs to trap the arrow keys to move items around internally. However, using the arrow keys will move the focus to another control on the form hosting the user...
1
by: Martijn Mulder | last post by:
/* I have problems detecting the Arrow Keys on a User Control. A control derived from System.Windows.Forms.Control neglects 'bare' Arrow Keys but does react on the combination <Altor <Ctrl+ Arrow...
0
by: Martijn Mulder | last post by:
/* I override IsInputKey() to direct the Arrow Keys (Cursor Keys) to my custom System.Windows.Forms.Control. But, holding down the Shift-Key prevents the Arrow Keys from coming through. How can...
4
by: boopsboops | last post by:
Hi thescripts people, I hope I'm in the right forum for Visual Basic Dotnet (VS 2005). I am trying to make a custom control in which you can nudge a point around using the arrow keys. Actually,...
0
by: Andrus | last post by:
I have combobox column in DataGridView. Up and down error keys should be used to navigate previous and next row in grid. For this I override them in ProcessCmdKey() event. When combobox...
2
by: Charles Law | last post by:
I'll kick myself when you tell me, but ... I have a user control on a form, and I want the user control to see the arrow keys when I press them. If I press just about any other key the control's...
4
by: beary | last post by:
Hi Being tested using FF 3 on WAMP server. I have spent a number of hours trying to figure this out myself. I have a html form using table cells and had a request to enable the arrow keys on a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.