在 javascript Event 对象中,有一些布尔值来检查是否按下了修饰键:
In the javascript Event object, there are some boolean values to check if modifier keys are pressed:
ctrlKey:CTRL键.altKey:ALT键.altLeft:ALT 左键.仅适用于 IE.altGraphKey:ALTGR 键.仅适用于 Chrome/Safari.ctrlKey: CTRL key.altKey: ALT key.altLeft: ALT left key. Only for IE.altGraphKey: ALTGR key. Only for Chrome/Safari.但是,有一些问题:
ctrlKey 设置为 true 并将 altKey 设置为 true.ctrlKey 设置为 false 并将 altKey 设置为 true,因为只有 ALT已按下.altGraphKey 属性,但它始终是 undefined.ctrlKey to true and altKey to true when you press the ALTGR modifier.ctrlKey to false and altKey to true when you press the ALTGR modifier, as only ALT has been pressed.altGraphKey property, but it is always undefined.问题:如何区分 ALT+CTRL 或 ALTGR 按键?特别是在 Chrome 中.
Question: how can I difference between an ALT+CTRL or an ALTGR key press? Specially in Chrome.
webkit 浏览器中的 altGraphKey 似乎不再存在(截至 2013 年 9 月),并且 Firefox 的行为发生了变化.AltGr 键的浏览器行为当前似乎是:
The altGraphKey in webkit browsers no longer appears to exist (as at September 2013) and the behaviour of Firefox has changed. Browser behaviours for the AltGr key currently appear to be:
也就是说,它们当前都是一致的(除了 IE8,它仍然始终不一致).
Which is to say, they are all currently consistent (apart from IE8, which remains consistently inconsistent).
以下代码段应该在现代浏览器中捕获 Alt Gr - 但不是 Alt 或 Ctrl -.但是,您将需要 IE8 的特殊情况:
The following snippet should catch Alt Gr - but not Alt or Ctrl - in modern browsers. You will need a special case for IE8 however:
if (event.ctrlKey && event.altKey) {
// Appears to be Alt Gr
}
这篇关于在按键上检测 Alt Gr(Alt Graph)修饰符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
在 Angular 2/Typescript 中使用 IScrollUse IScroll in Angular 2 / Typescript(在 Angular 2/Typescript 中使用 IScroll)
Anime.js 在 Ionic 3 项目中不起作用anime.js not working in Ionic 3 project(Anime.js 在 Ionic 3 项目中不起作用)
Ionic 3 - 使用异步数据更新 ObservableIonic 3 - Update Observable with Asynchronous Data(Ionic 3 - 使用异步数据更新 Observable)
Angular 2:在本地 .json 文件中找不到文件Angular 2: file not found on local .json file(Angular 2:在本地 .json 文件中找不到文件)
在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指In Ionic 2, how do I create a custom directive that uses Ionic components?(在 Ionic 2 中,如何创建使用 Ionic 组件的自定义指令?)
将 ViewChild 用于动态元素 - Angular 2 &离子2Use ViewChild for dynamic elements - Angular 2 amp; ionic 2(将 ViewChild 用于动态元素 - Angular 2 amp;离子2)