检测键盘上所有按下的按键 [英] Detect all the Key Pressed in keyboard

查看:215
本文介绍了检测键盘上所有按下的按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以检测在窗体的keydown事件中按下的所有键? 例如,当前正在按CRTL + Alt + A,我可以在按键事件中获取所有按键吗?我需要获取所有密钥才能在当前正在开发的应用程序中创建自己的热键

is there a way to detect all the key pressed in keydown event of the form? For example im currently pressing CRTL + Alt + A can i get all the keys in keydown event? i need to get all the keys to create my own hot keys in my currently developing application

推荐答案

如果要查找按下了哪些键,可以这样做

If you want to find which keys are pressed, you could do this,

     if ((Keyboard.Modifiers & ModifierKeys.Alt) == ModifierKeys.Alt) // Is Alt key pressed
        {
            if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyDown(Key.A))
            {
                MessageBox.Show("Key pressed"); 
            }
       }

这篇关于检测键盘上所有按下的按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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