简体   繁体   English

检测用户是否使用 ANSI 或 ISO 键盘按钮布局

[英]Detect if user is using ANSI or ISO keyboard button layout

I'm currently working on a custom key binding mod for Minecraft.我目前正在为 Minecraft 开发自定义键绑定模块。 Although irrelevant, it gives some context.尽管无关紧要,但它提供了一些上下文。 I'm planning to show a UI with all the buttons on their keyboard where they can click to assign macros to said key, although I don't want to be biased towards one particular keyboard button layout.我计划展示一个用户界面,其中包含键盘上的所有按钮,他们可以在其中单击以将宏分配给所述键,尽管我不想偏向于一种特定的键盘按钮布局。

Looking at a website called switchandclick they show the differences between ISO and ANSI.查看一个名为switchandclick的网站,他们显示了 ISO 和 ANSI 之间的差异。 ISO which I'm using has a key between left shift and Z, as well as having the return/enter key 2 keys tall rather than 1, with the missing key moved above right shift.我使用的 ISO 在左移和 Z 之间有一个键,以及返回/输入键 2 个键高而不是 1 个,缺少的键移到右移上方。

Here is the image from said site:这是来自上述网站的图片: ansi 与 iso 图像

However, even if ISO is the layout used in Sweden where I live, I'm aware some users may be from different parts of the world, and ANSI is probably more common in America, so I don't want to show an ISO keyboard for ANSI users and vice versa.但是,即使 ISO 是我居住的瑞典使用的布局,我知道有些用户可能来自世界不同地区,而 ANSI 在美国可能更常见,所以我不想展示 ISO 键盘对于 ANSI 用户,反之亦然。

I've looked around at various sources, but all I can find when looking for a solution is websites showing the differences between the layouts, rather than showing how to detect them.我查看了各种来源,但在寻找解决方案时,我只能找到显示布局之间差异的网站,而不是展示如何检测它们。

So how would I go about detecting if the user has an ANSI or ISO keyboard?那么我将如何检测用户是否有 ANSI 或 ISO 键盘? Pure Java is preferred but LWJGL 3 is the graphics api in use if that helps with finding a solution.纯 Java 是首选,但 LWJGL 3 是使用中的图形 api,如果这有助于找到解决方案。 I'm also running Java 17 in case that makes it easier.我也在运行 Java 17,以防万一。

As mentioned by @Abra in a comment to the question, there's no way to do that programmatically as there's no protocol between the keyboard controller and the keyboard driver that helps distinguish the layout of the keyboard.正如@Abra在对该问题的评论中提到的那样,无法以编程方式执行此操作,因为键盘控制器和键盘驱动程序之间没有有助于区分键盘布局的协议。

Only option here is to either guess/predict the layout, let the user choose the layout, or simply use the same layout assumed by Windows in osk.exe.这里唯一的选择是猜测/预测布局,让用户选择布局,或者简单地使用 Windows 在 osk.exe 中假定的相同布局。

Original answer on this post这篇文章的原始答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM