I'm trying to capture when a user presses a particular key (escape), so
I'm coding in the KeyPress event. Yet the code seems be bypassed
(breakpoint is never encountered). Should I be coding in a different
event? Is this a known issue? FYI, this is happening in both Access 97
and 2000. 8 37109
On Tue, 09 Sep 2003 17:20:52 GMT, William Ortenberg wrote: I'm trying to capture when a user presses a particular key (escape), so I'm coding in the KeyPress event. Yet the code seems be bypassed (breakpoint is never encountered). Should I be coding in a different event? Is this a known issue? FYI, this is happening in both Access 97 and 2000.
You have to set "KeyPreview " = true.
Also, you should know about the difference between KeyDown, KeyUp and
KeyPress. See OH.
HTH - Peter
--
No mails please.
This posting is provided AS IS with no warranties, and confers no rights.
William Ortenberg <bi*****@pacbel l.net> wrote in message news:<UZ******* *******@newssvr 29.news.prodigy .com>... I'm trying to capture when a user presses a particular key (escape), so I'm coding in the KeyPress event. Yet the code seems be bypassed (breakpoint is never encountered). Should I be coding in a different event? Is this a known issue? FYI, this is happening in both Access 97 and 2000.
William,
The keypress-event does only respond to ANSI-characters and not to
non-text keys like escape, enter, cursor-keys, Home PgDn etc. The
effect of the shift-keys result in another character if valid. The
keyUp end KeyDown events however do respond to the escape-key and give
back a numeric value for each physical key with some exeptions and
conditions depending on the form-properties (see url http://msdn.microsoft.com/library/de...acevtKeyUp.asp
etc)
Other than fhe keypress-event they also return the state of the shift,
control and alt-key states seperately.
see also the useful article http://users.bigpond.net.au/abrowne1/ser-34.html
Marc
> The keypress-event does only respond to ANSI-characters and not to non-text keys like escape, enter, cursor-keys, Home PgDn etc. ...
Try this:
Key Preview=Yes
Private Sub Form_KeyPress(K eyAscii As Integer)
If KeyAscii = vbKeyEscape Then
MsgBox "ESC pressed."
End If
End Sub
Peter
--
No mails please.
This posting is provided AS IS with no warranties, and confers no rights.
This is not correct. You should use the KeyDown event for this, not
KeyPress.
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
"Peter Doering" <ne**@doering.o rg> wrote in message
news:bj******** ****@ID-204768.news.uni-berlin.de... The keypress-event does only respond to ANSI-characters and not to non-text keys like escape, enter, cursor-keys, Home PgDn etc. ...
Try this:
Key Preview=Yes
Private Sub Form_KeyPress(K eyAscii As Integer) If KeyAscii = vbKeyEscape Then MsgBox "ESC pressed." End If End Sub
Peter
-- No mails please. This posting is provided AS IS with no warranties, and confers no rights.
> This is not correct. You should use the KeyDown event for this, not KeyPress.
I know!
The statement was that KeyPress won't respond to ESC, but it does. I've
tested it.
Peter
The point is that it is foolish to rely on it, since apps will often trap
and remove the keystroke before it ever makes it to a WM_CHAR message (the
basis of the KeyPress event). Reliable code is always better....
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
"Peter Doering" <ne**@doering.o rg> wrote in message
news:bj******** ****@ID-204768.news.uni-berlin.de... This is not correct. You should use the KeyDown event for this, not KeyPress.
I know!
The statement was that KeyPress won't respond to ESC, but it does. I've tested it.
Peter
> The point is that it is foolish to rely on it, since apps will often trap and remove the keystroke before it ever makes it to a WM_CHAR message (the basis of the KeyPress event). Reliable code is always better....
Thanks. For common people who rely on OH this is not really obvious. Is
there a place where one can read about it?
When would you use KeyPress or KeyUp?
Peter
--
No mails please.
KeyDown and KeyUp are responding to WM_KEYDOWN and WM_KEYUP messages, and
KepPress resonds to a WM_CHAR message. The first to respond to physical
keystroke push/release, while the latter responds to when a message loop
asks Windows to translate that keystroke to a character.
--
MichKa [MS]
This posting is provided "AS IS" with
no warranties, and confers no rights.
"Peter Doering" <ne**@doering.o rg> wrote in message
news:bj******** ****@ID-204768.news.uni-berlin.de... The point is that it is foolish to rely on it, since apps will often
trap and remove the keystroke before it ever makes it to a WM_CHAR message
(the basis of the KeyPress event). Reliable code is always better....
Thanks. For common people who rely on OH this is not really obvious. Is there a place where one can read about it?
When would you use KeyPress or KeyUp?
Peter
-- No mails please. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Trevor Fairchild |
last post by:
I'm writing a program that is designed for quick navigation using
specific buttons on the keyboard. In doing this, I have added a
KeyPress event for every control on the form to intercept the key
pressed and pass it to a standard subroutine that identifies what
action should be taken.
Unfortunately, I have a web-browser contol on the form and the
webbrowser does not include a KeyPress event.
I need some way to intercept keypress and...
|
by: Darryn Ross |
last post by:
Hi,
I am trying to catch the KeyPress event on my datagrid but it isn't
working... i have also tried registering the handler with the event like
this...
dgGLBatch.KeyPress += new KeyPressEventHandler(dgGLBatch_KeyPress);
but nothing changed. I was wondering wether a custom table and column style
might have an effect on how this works???
|
by: Raul M. Colon |
last post by:
Is possible to assign a click event to a button control in a Web form just
pressing the return key? Something like windows forms where you can assign
this action to a default control. For example, if I press Return, I want to
fire the button_click event even when the button is not in focus. Any
thoughts?
Thanks!
Raul
|
by: Tom |
last post by:
I have a VB.NET user control that I wrote - this control has three or four
other controls on it (textbox, combobox, datetime picker, etc). Now,
whenever the control is on a form and the user enters anything into the
textbox (for instance) I trap the keypress event to handle some stuff (i.e.
if it is an enter key, etc). Now, once I am done with handling the keypress
event for the textbox, I then need to pass that keypress event BACK to the...
|
by: Terry Olsen |
last post by:
Is there anyway to cause a KeyPress event in a datagrid cell? The only way
I get a keypress event is if none of the cells are selected. I was hoping
to have the program respond to a certain keypress while in a cell of a
datagrid but it doesn't fire the keypress event.
| |
by: Just Me |
last post by:
I noticed that I don't get KeyDown nor KetPress events if NumLock is not on.
I can probably find a workaround but it would be nice to know what the rules
are.
Can anyone tell me when KeyPress event is raised and when it isn't.
Thanks
|
by: Nikolay Evseev |
last post by:
Hi,
I am trying to trace down the Enter key in my Form.KeyPress event handler.
The KeyPreview property is set to false, so I'd assume that all key presses
should go through my form's KeyPress event handler, right? Ok. If the focus
is set to any other control than a button, then the above event handler
fires, but if the focus is on a button, then I've no way to know that the
Enter key has been pressed or not, because in that case pressing...
|
by: Kay |
last post by:
Hi all,
I want to create a small function to monitor the keystroke. For example, if
user key in a comma, I want to replace it with a single quote(etc)... In
vb6 I an simply check the KeyAscii in the keypress event and re-assign the
value to it, however how do I achieve this result in .net? Thanks~
Kay
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |