使用javascript检测键盘布局 [英] detect keyboard layout with javascript

查看:366
本文介绍了使用javascript检测键盘布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用JavaScript检测当前的键盘布局?我发现这个
但它只检测到如果访客是英语布局。我需要知道确切的布局为字符串,例如 de-ch fr en

Is there any way to detect the current keyboard layout using JavaScript? I found this, but it only detects if the visitor is on the english layout. I need to know the exact layout as a string, e.g.de-ch, fr or en.

推荐答案

键盘布局没有标准化标识符。它们具有布局创建者为其分配的名称。它们可能将语言关联作为一个已定义的属性。

Keyboard layouts do not have standardized identifiers. They have names assigned to them by the layout creator. They may have a language association as one defined property.

不应将键盘布局与语言或区域设置标识符混淆。特别是没有单一的英语布局,但有几十种布局可用于英语。

The Keyboard layouts should not be confused with language or locale identifiers. In particular there is no single "English layout" but dozens of layouts that may be used for English.

我不认为系统通常会通过系统读取当前的布局设置JavaScript。

I don’t think systems normally make their current layout settings readable via JavaScript.

因此,无论你通过检测键盘布局解决什么问题,都需要采用不同的方法。

So whatever problem you are trying solve by detecting the keyboard layout, a different approach is needed.

这篇关于使用javascript检测键盘布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆