shift 按下,然后自动向上?(避免长按) [英] shift pressed, and automatically up?(to avoid long press and hold)

查看:83
本文介绍了shift 按下,然后自动向上?(避免长按)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些帮助...如何在按下 shift 时使其成为可能,

Some help on... how to make it possible when shift is pressed,

然后系统瞬间自动释放,

then the system automatically released it in split second,

因此即使用户仍然在键盘上按下它,

hence even though it is still pressed in the keyboard by the user,

但是vb.net系统已经放出了shift键?

but the vb.net system already released the shift key?

避免长按或按住键...

to avoid long press or hold on the key...

我已经很不明白了,因此在做了一些认真的研究后决定在这里发布一个问题,如果您知道一些使这成为可能的技巧,请回复......

I'm so out of idea already, hence decided to post a question here after doing some serious researches, please respond if you know some tricks to make this possible...

推荐答案

您可以处理 KeyDown 事件并检查是否按下了 Shift.

You can handle KeyDown event and check if Shift is pressed.

e.KeyCode = Keys.Shift

您可以使用 user32.dll 库并发送密钥版本.&H10Shift 键码.这里所有键码的列表(将 0x 替换为 &H).&H2 表示发布.如果您想,请输入 &H0.

You can work with user32.dll lib and send the key release. &H10 is Shift key code. Here is a list of all key codes (replace 0x with &H). &H2 means release. Type &H0 if you want to press.

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)

keybd_event(&H10, 0, &H2, 0)

您可能想要处理整个表单的 KeyDown 事件.

You may want to handle entire form's KeyDown events.

Form.KeyPreview = True

这是一个例子.

Public Class Form1
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)

    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Me.KeyPreview = True
    End Sub

    Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If e.KeyCode = Keys.Shift Then
            Form1.keybd_event(&H10, 0, &H2, 0)
        End If
    End Sub
End Class

这篇关于shift 按下,然后自动向上?(避免长按)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆