| |

VerySource

 Forgot password?
 Register
Search
View: 4191|Reply: 12

Why can't my form respond to keyboard events

[Copy link]

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-7 12:00:01
| Show all posts |Read mode
I respond to the KeyPress and KeyDown events in the Form. Why ca n’t I trigger the event when I press the keyboard? Sometimes I do n’t know what ’s going on.
Reply

Use magic Report

0

Threads

2

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-7 19:09:01
| Show all posts
Is the KeyPreview property of the form not set to true?
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-1-8 06:00:02
| Show all posts
KeyPreview = true and the focus is on the form.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-10 20:09:01
| Show all posts
If it is KeyPress, some keys will not respond to the event, such as arrow keys and auxiliary keys.
But KeyDown should not be like this? As long as the keys on the keyboard will respond to this event, I do n’t know which event you are using
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Unknown

Post time: 2020-1-17 16:27:01
| Show all posts
KeyPreview = true
form.setfocus
Reply

Use magic Report

1

Threads

21

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 Great Britain

Post time: 2020-1-17 21:45:01
| Show all posts
KeyPreview = true
form.setfocus

It also depends on whether you pressed the function key. Del and tab do not seem to respond.
Reply

Use magic Report

0

Threads

16

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-1-26 10:54:01
| Show all posts
Focus on issues
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-29 14:45:01
| Show all posts
Look at the following Enabled
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-2-1 21:18:02
| Show all posts
form.setfocus ?? Does this work?
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-2 10:18:02
| Show all posts
I think there should be something wrong with the explanation of the landlord:
These should be two trigger events, not just a matter of the form's [KeyPreview] property:

Explanation:
Assume a response to a keyboard return:
Private Sub Form_KeyPress (KeyAscii As Integer)
    if keyascii = 13 then msgbox "Enter"
End Sub
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list