ContentEditable元素不对热键做出反应 [英] ContentEditable element does not react on hotkeys

查看:186
本文介绍了ContentEditable元素不对热键做出反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Chrome扩展程序,将JS代码注入所有打开的标签页。此代码的任务包括显示一个文本框,实现为 contentEditable < div> 以允许格式化。但是, contentEditable 元素在某些网站上的表现不佳,例如

I'm developing a Chrome extension that injects JS code into all opened tabs. The task of this code includes displaying a textbox, implemented as a contentEditable <div> to allow formatting. However, the contentEditable element doesn't play well with some websites, e.g. Twitter.

自己尝试:


  1. 转到 twitter.com

  2. 粘贴 javascript:document。 body.setAttribute('contentEditable',true); 在地址栏中,然后按Enter键。

  3. 单击文档中的任意位置 - 您现在应该可以编辑

  4. 尝试输入一个 j k 。您将看到:该角色不会出现,相反,选择被移动(列表中的推文将被突出显示)。

  1. Go to twitter.com
  2. Paste javascript:document.body.setAttribute('contentEditable', true); in the address bar and hit enter.
  3. Click anywhere in the document - you should now be able to edit the text.
  4. Try typing a j or k. You will see: The character does not appear, instead, the selection is moved (a tweet in the list will be highlighted).

我已经努力找出Twitter的键盘导航如何实现,但找不到任何提示。你可以给我任何关于如何解决这个问题的提示(并避免在其他网站上出现类似的问题)?

I have tried hard to find out how Twitter's keyboard navigation is implemented, but could not find any hints. Can you give me any tips on how to solve this problem (and avoid similar problems on other websites)?

使用iFrame输入会触发一些其他非常奇怪的错误,所以我想避免这种情况。

Using an iFrame for the input triggers some other, very weird bugs, so I want to avoid that if it's possible.

推荐答案

请确保您没有在google上安装vim键盘扩展名铬。
J和K然后用于导航快捷方式。 (上/下)。

Please make sure you don't have installed vim keyboard extension on google chrome. J and K are then used for navigation shortcuts. (up/down).

这篇关于ContentEditable元素不对热键做出反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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