我有一个带有键盘快捷键的脚本,如下所示:
private void MainView_KeyDown(object sender, KeyEventArgs e)
{
if (e.Control && e.KeyCode == Keys.S)
{
backstageViewButtonItem_Save_ItemClick(null, null);
}
if (e.Control && e.Alt && e.KeyCode == Keys.S)
{
backstageViewButtonItem_SaveAs_ItemClick(null, null);
}
}
问题: 当我按下 AltRs + s 时,我的保存功能被触发。看起来 AltRs 被视为 ctrl+alt。
有没有可能认识到它只是按下alt,而不是ctrl+alt,所以这个功能不会被触发?
最佳答案
根据 https://en.wikipedia.org/wiki/AltGr_key :
To allow the specific functionality of AltGr when typing non-English text on such keyboards, Windows allows it to be emulated by pressing the Alt key together with the Control key
...
Therefore, it is recommended that this combination not be used as a modifier in Windows keyboard shortcuts...
所以:不要那样做。
关于c# - 按键事件 'AltGr + S' 被视为 'Ctrl + alt + s',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52758231/