Windows Develop Bookmark and Share   
 index > Windows Forms General > Detect user press the "Enter" Button
 

Detect user press the "Enter" Button

Hi All,

Can i through some method to detect the user is press the "Enter" button or not?

("Enter" Button on the Keyboard.)

Thx a lot.
Thx a lot.
Thx a lot.

Laputa
MigrationUser 1  Thursday, June 24, 2004 10:06 PM
Well, I currently use the KeyPress handler to do this:

private void OnKeyPress(object sender,KeyPressEventArgs e)
{
switch (e.KeyChar)
{
case '\x0d':
//handle the return key
break;
}
}
private void OnKeyDown(object sender,KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Return:
//handle the return key
break;
}
}

The KeyDown (simular KeyUp) code I added to show that the key is also available in these handlers, as said for some reason I ended up handling the key in the KeyPress handler, but other options exist as well.
I hope this helps.
MigrationUser 1  Friday, June 25, 2004 1:09 AM
Let me try it.

Thx a lot!!!!!!

Laputa
MigrationUser 1  Friday, June 25, 2004 1:58 AM

You can use google to search for other answers

Custom Search

More Threads

• side panel on a windows form
• XmlDocument Error
• How to get a pathname to a file in my project
• Minimized Windows Completely Disappear, however, they can be found in Task Manager as Active/Running programms!
• How to trap for esc key in a loop?
• WF2WF
• Custom Menu's
• treeview get node select
• Control Arrays
• phone connect