箭头键在输入和文本区域不工作

时间:2022-05-25 17:24:13

I have a simple textarea and input in my webapplication. For some reason, I cannot go back in the typed text with the arrow keys. The input cursor does not move backwards.

我有一个简单的textarea和输入在我的webapplication。由于某种原因,我无法返回带有箭头键的输入文本。输入光标不会向后移动。

I can however use ctrl+a, or click the with the mouse on the position that I want to edit. This is confusing. I am not using e.preventDefault in any key event in my code - having around 30 js files and some huge css files -.

但是我可以使用ctrl+a,或者用鼠标点击我想编辑的位置。这是令人困惑的。我没有用e。在我的代码中任何一个关键事件中都有防止默认值——有大约30个js文件和一些巨大的css文件。

Any ideas on why the arrows might not work?

你知道为什么箭头不能工作吗?

Thanks!

谢谢!

2 个解决方案

#1


6  

Do a search in all your JS files and look for something similar to:

在所有JS文件中进行搜索,查找类似于:

keyCode == 37

or

which == 37

as this is the left-arrow. Probably somewhere there is something similar to:

因为这是左箭头。可能有一些类似的东西:

if (e.keyCode == 37)
   e.preventDefault();

#2


0  

Just to add a comment to help people loading input and textareas inside a lightbox. Most lightboxes bind the arrow keys to photo navigation (previous,next), so the arrow keys will not work in your form fields.

只需添加一条注释,帮助人们在lightbox中加载输入和文本区域。大多数lightbox将箭头键绑定到照片导航(下一个),所以箭头键不会在表单字段中工作。

To fix that, just search the javascript code of your lightbox for the keycodes (as Jules suggested) and remove the code block that binds the arrow keys. Or you can condition it.

要解决这个问题,只需搜索lightbox的javascript代码(如朱尔斯所建议的),并删除绑定箭头键的代码块。或者你可以设置它。

For example, in right-lightbox.js the keybinding code is

例如,在right-lightbox。键绑定代码是

var b=p.current,c=({27:"close",33:"prev",37:"prev",38:"prev",39:"next",40:"next",34:"next"})[a.keyCode];

27 is the escape key, so you can leave that there, and remove the rest.

27是escape键,所以你可以把它放在那里,然后删除其余的。

#1


6  

Do a search in all your JS files and look for something similar to:

在所有JS文件中进行搜索,查找类似于:

keyCode == 37

or

which == 37

as this is the left-arrow. Probably somewhere there is something similar to:

因为这是左箭头。可能有一些类似的东西:

if (e.keyCode == 37)
   e.preventDefault();

#2


0  

Just to add a comment to help people loading input and textareas inside a lightbox. Most lightboxes bind the arrow keys to photo navigation (previous,next), so the arrow keys will not work in your form fields.

只需添加一条注释,帮助人们在lightbox中加载输入和文本区域。大多数lightbox将箭头键绑定到照片导航(下一个),所以箭头键不会在表单字段中工作。

To fix that, just search the javascript code of your lightbox for the keycodes (as Jules suggested) and remove the code block that binds the arrow keys. Or you can condition it.

要解决这个问题,只需搜索lightbox的javascript代码(如朱尔斯所建议的),并删除绑定箭头键的代码块。或者你可以设置它。

For example, in right-lightbox.js the keybinding code is

例如,在right-lightbox。键绑定代码是

var b=p.current,c=({27:"close",33:"prev",37:"prev",38:"prev",39:"next",40:"next",34:"next"})[a.keyCode];

27 is the escape key, so you can leave that there, and remove the rest.

27是escape键,所以你可以把它放在那里,然后删除其余的。