Multi Key Hotkeys in VB 2010

孤街浪徒 提交于 2019-12-11 11:33:38

问题


I've written a simple WAV player in VB 2010 - a Windows Form App with no menus. I'm trying to create a hotkey, like CTRL-D that would make a text box visible. Typing the correct password in the box will expand the form and show some Administrative functions. I'm having issues creating the hotkey with more than one key.

I've got the following code, but it does not work. I do have KeyPreview set to True.

Private Sub _KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    If e.KeyCode = Keys.Control And e.KeyCode = Keys.D Then
        txtPWD.Visible = True

I've also tried

If e.Keycode = Keys.ControlKey & e.KeyCode = Keys.D

and many other variations including changing to ALT and SHIFT but nothing seems to work. If I remove one of the Keys, it works just fine. Where am I getting this wrong?


回答1:


Check for Modifierkeys:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.modifierkeys.aspx



来源:https://stackoverflow.com/questions/9438410/multi-key-hotkeys-in-vb-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!