[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

problem with keypress VS keydown

Posted on 2004-09-29
6
Medium Priority
?
1,242 Views
Last Modified: 2008-02-01
I put some coding both in the keypress event and keydown event. but the keypress event is not fired why? is it keydown suppress keypress?
0
Comment
Question by:jessi_vs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 33

Expert Comment

by:hongjun
ID: 12177486
post your code.
0
 
LVL 10

Expert Comment

by:ADSaunders
ID: 12177538
Hi jessi_vs,
Is the keypress event in the form or in a control on the form? If it is on the form, the keypress will only be seen if the KeyPreview property of the form is set to true.

Regards .. Alan
0
 
LVL 8

Expert Comment

by:mladenovicz
ID: 12177755
keypress event occurs when the user presses and releases an ANSI key.The object with the focus receives the event.
keydown event occurs when the user presses a key while an object has the focus.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 12

Expert Comment

by:jkaios
ID: 12187451
Yes, if both the KeyDown and KeyPress events are present, then the "KeyDown" event would fire, thus suppressing the KeyPress event.
0
 

Author Comment

by:jessi_vs
ID: 12187473
thanks, let me check it up. both events or in a textbox.
0
 
LVL 12

Accepted Solution

by:
jkaios earned 80 total points
ID: 12187772
Perhaps you might want to try this to confirm.

1. Place a text box on the form and call it Text1
2. Paste the following codes below
3. Run your app the hit some key -- you should confirm that only the KeyDown event fires

-----------------[Start of Code] ----------------------------------------------------------------

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
 MsgBox "KeyCode = " & KeyCode, , "Text1_KeyDown"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
 MsgBox "KeyAscii = " & KeyAscii, , "Text1_KeyPress"
End Sub

-----------------[End of Code] -----------------------------------------------------------------

P.S.
  The advantage of KeyDown event is that it can detect the Navigation keys, such as
  the PageUp, PageDown, Home, End keys. It can also detect the Delete and Back Space
  and the Function keys.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question