gpt4 book ai didi

c# - C#中如何获取组合键

转载 作者:可可西里 更新时间:2023-11-01 08:55:28 24 4
gpt4 key购买 nike

如何捕获 C# 窗体上的 Ctrl + Alt + K + P 键?谢谢

最佳答案

这是一个和弦,如果不记住看到和弦的第一个击键,就无法检测到它。这有效:

public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private bool prefixSeen;

protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
if (prefixSeen) {
if (keyData == (Keys.Alt | Keys.Control | Keys.P)) {
MessageBox.Show("Got it!");
}
prefixSeen = false;
return true;
}
if (keyData == (Keys.Alt | Keys.Control | Keys.K)) {
prefixSeen = true;
return true;
}
return base.ProcessCmdKey(ref msg, keyData);
}
}

关于c# - C#中如何获取组合键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3244063/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com