c# - 按键事件 'AltGr + S' 被视为 'Ctrl + alt + s'

标签 c#

我有一个带有键盘快捷键的脚本,如下所示:

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/

相关文章:

C#如何获取字符串中字符的长度

c# - LINQ 查询字符串[] 按多个匿名列分组

c# - 如何获取服务器上打开的 HTTP 连接总数?

c# - 如何计算给定索引周围 bool[,] 中的真实值?

c# - 地址的地理经度和地理纬度

c# - 保持IEnumerable和ObservableCollection同步

c# - 最佳实践代码和问题

c# - 如何设置 MigraDoc 的页面大小?

c# - 从 JSON 自动生成 C# 类,包括属性初始值设定项

c# - 如何通过 Threads c# 将节点添加到 TreeView 中?