Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KeyPress vs KeyDown 1

Status
Not open for further replies.

zarkon4

MIS
Dec 16, 2003
641
US
I have developed an application for PocketPC 2003 and am capturing the Enter key in the Keydown event.
I changed the target device to Windows Mobile 5.0 and deployed. The Enter key is not being captured. I called tech support for the device and am being told I must capture it within the KeyPress event. I am in disagreement with them on this and want them to fix the problem. I do not want to have to change my application for this.

Hence my question, Which event is the preferred/recommended to capturing the Enter key?
 
KeyPress should be fine. You only need to use KeyDown for non-character keys (control, alt, shift, windows, F#, directionals, etc...) or for times when you need to trigger different events on the key down and key up (such as GUI changes).

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks,

Would you agree that if I press the Enter key it should
give me an ascii 13 no matter which event I use?

That is the problem I am having, in the keypress I get ascii 13, in the keydown I get F23. In order for the enter key to work in the keydown event I must press Func-CTRL-Enter.
 
I can use it, just alot of code changes. But it leaves them off the hook on correcting the problem. If I press the enter key it should be the enter key.
 
Keypress is not returning ASCII values because Shift, Control, Alt, Arrows, Home, End, etc... do not have ASCII values.

e.KeyData and e.KeyCode are going to return Windows.Forms.Keys objects which can be compared against the desired key. e.KeyValue is returning an integer value representing the key's value to the keyboard, not it's ASCII value.

If you want to stick with the KeyDown method, you should compare e.KeyCode to Keys.Enter.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks...I am comparing e.keycode to keys.enter, it is returning something wierd. So I called the mobile device tech support. They did know of a problem with the enter key when using pocket word or excel and notes and gave me a reg fix, the reg fix only worked for those apps and not mine.
I am still waiting to hear back from them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top