在浏览器中重写TAB [英] Override TAB inside a Browser

查看:97
本文介绍了在浏览器中重写TAB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在输入字段中输入文本并按下 ENTER ,我知道所有浏览器的默认行为是提交表单,但是如果按 ENTER 在textarea里添加一个新行。



有没有什么办法模仿这种行为(indent,每当我在textarea内按 TAB Bespin 似乎这样做,但是在 canvas 元素中。

解决方案

我自己并没有这样做,但似乎可以重写事件处理程序并捕获密钥。见例如此处



哦,对于JQuery人群来说,甚至还有一个插件

If I'm typing text in a input field and press ENTER the default behavior of all the browsers I know is to submit the form, however if I press ENTER inside a textarea a new line is added.

Is there any way to mimic this behavior (indent, not submit the form) whenever I press TAB inside a textarea? Bespin seems to do it, but in a canvas element.

解决方案

I haven't done it myself, but it seems to be possible to override the event handler and catch the key. See e.g. here.

Oh and for the JQuery crowd there even is a plugin.

这篇关于在浏览器中重写TAB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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