rk键盘快捷键快捷键不一致_为什么其他键盘语言的键盘快捷键和可访问性很少起作用...

rk键盘快捷键快捷键不一致

Using keyboard shortcuts are important both if you have accessibility problems but also just in general as it is much more precise using the keyboard than reaching out for the mouse and pointing.

使用键盘快捷键不仅在您遇到可访问性问题时很重要,而且在一般情况下也是如此,因为使用键盘快捷键比伸出鼠标和指向要精确得多。

Sadly keyboard shortcuts never seem to work probably if you are using a non-english keyboard layout, but why is that? You would think that typing “Shift+?” would give the same result no matter which language you speak and the same “/”.

可悲的是,如果您使用的是非英语键盘布局,键盘快捷键似乎永远无法工作,但是为什么呢? 您会以为输入“ Shift +?” 无论您使用哪种语言和相同的“ /”,都会得到相同的结果。

On facebook you can get this menu if you type “Shift+?”, but typing “/” does not work on a danish keyboard layout:

在facebook上,如果您键入“ Shift +?”,则可以得到此菜单,但是在丹麦语键盘布局上键入“ /”不起作用:

The reason is that browsers are weird and developers don’t use the same way to recognize which character was pressed.

原因是浏览器很奇怪,开发人员没有使用相同的方式来识别按下了哪个字符。

Image for post

To see it for yourself, try going to https://keycode.info/ with your native keyboard and switch keyboard layout in your OS, then look at this image to know which key is now which on a English keyboard:

要亲自查看,请尝试使用本机键盘转到https://keycode.info/并在操作系统中切换键盘布局,然后查看此图像以了解现在哪个键是英语键盘上的哪个键:

Image for post
Wikipedia 维基百科

代码中的问题 (The problem in the code)

This is the code for “/” in danish keyboard layout. On our keyboard you need to press Shift and the key 7:

这是丹麦键盘布局中“ /”的代码。 在我们的键盘上,您需要按Shift键和键7:

Image for post

But on a English/American keyboard you type “/” by using the key 3 keys to the right of “m”.

但是在英/美键盘上,您可以使用“ m”右侧的3键输入“ /”。

Image for post

See how all but event.key are different! On english it is Slash or 191, but in danish it is Digit7 and 55.

看看除了event.key以外的所有东西都不同! 英文是Slash或191,丹麦文是Digit7和55。

如何解决? (How to fix it?)

The solution is to either:

解决方案是:

  • to stop using event.code and switch to event.key

    停止使用event.code并切换到event.key

  • based on the language of the user, know what event.code refers to what key on their keyboard

    根据用户的语言,知道哪个event.code指的是他们键盘上的哪个键

Either will take a long time to change. The reason is firstly a11y education (a11y = accessibility shortened by 11 letters) and developers like numbers in programming languages as comparing numbers are faster in CPU time and more convenient.

两者都需要很长时间才能更改。 原因首先是a11y教育(a11y =可访问性缩短了11个字母),开发人员喜欢编程语言中的数字,因为比较数字在CPU时间上更快,更方便。

Here for example digging into the facebook frontend code, you can see it in action:

例如,在这里深入研究Facebook前端代码,您可以看到它的运行情况:

Image for post
This line turns the “/” into a number
这行将“ /”转换为数字
Image for post
Next line where b has been turned into “7”
b已变成“ 7”的下一行
Image for post
and later in Facebook.com code it turns into “shift 7” 😕
然后在Facebook.com代码中变成“ shift 7””
Image for post
o only has two commands, “shift ?” and “/”, no “shift 7”! o只有两个命令,“ shift?” 和“ /”,没有“ shift 7”!

Here you can see Facebook compare with keyCode and which to see if I typed “55”, which is “7”. But you can see that MDN (Mozilla Web docs) says that both keyCode and which has a 👎 and it says “Warning: This attribute is deprecated; you should use KeyboardEvent.key instead, if available.” under the section “Obsolete properties”.

在这里,您可以看到Facebook与keyCode进行比较,并查看我是否键入了“ 55”(即“ 7”)。 但是你可以看到,MDN(Mozilla的网页文档)说,这两个keyCodewhich有一个👎和它说:“ 警告:该属性是不鼓励; 您应该改用KeyboardEvent.key (如果有)。” 在“过时的属性”部分下。

and even code has this big sign:

甚至code也有这个大标志:

Image for post

松弛也做错了! (Slack also does it wrong!)

Also slack does it wrong, and since it is a Electron.js app (which mean a app mean with a embedded browser), it uses JavaScript and has the same errors:

松弛也错了,并且因为它是一个Electron.js应用程序(这意味着应用程序具有嵌入式浏览器),所以它使用JavaScript并具有相同的错误:

Image for post

It does not work sadly.

它不会令人遗憾地工作。

但是我们需要这种改变! 请与专注于可访问性的开发人员分享! (But we need this change! Please share this with your developers that focus on accessibility!)

And if your app don’t have a “Shift+?” menu, quickly make it! You know, all awesome websites has one. Did you check your favorite websites?

如果您的应用没有“ Shift +”键? 菜单,赶快做吧! 您知道,所有很棒的网站都有一个。 您是否检查了自己喜欢的网站?

翻译自: https://medium.com/@kevinsimper/why-keyboard-shortcuts-and-accessibility-in-other-keyboard-languages-rarely-works-8638abc15e71

rk键盘快捷键快捷键不一致

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值