扳机触发ALT
我想从form1_keypress中检测Alt或Alt +一些键。这是我的代码:
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (Control.ModifierKeys == Keys.Alt)
{
MessageBox.Show("Alt");
}
if (Control.ModifierKeys == Keys.Control)
{
MessageBox.Show("Control");
}
}
当我击中ctrl + a时,第二个如果触发。但是,当我击中Alt + A时,什么也不会发生。这是为什么?是否还有其他方法可以从form1_keypress触发alt?在这种情况下,我不想从键盘触发它。
I want to detect Alt, or Alt + some key, from within Form1_KeyPress. This is my code:
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (Control.ModifierKeys == Keys.Alt)
{
MessageBox.Show("Alt");
}
if (Control.ModifierKeys == Keys.Control)
{
MessageBox.Show("Control");
}
}
When I hit Ctrl + A for example, the second if triggers. However when I hit Alt + A for example, nothing happens. Why is that? is there some other way to trigger Alt from Form1_KeyPress? I don't want to trigger it from KeyDown in this instance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论