禁用键盘< enter>键 [英] Disable keyboard <enter> key

查看:90
本文介绍了禁用键盘< enter>键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想禁用键盘上的 Enter 键。由于某些原因,以下脚本会锁定整个键盘,除了仍然只允许使用 Enter 键。

I just want to disable the Enter key on the keyboard. The following script locks the whole keyboard down for some reason except for still allowing only the Enter key to be used.

如果这有助于找出遗漏或错误的内容,我正在使用V.S. 2005年,VB.NET 2.0和I.E. 7。

If this helps pinpoint what's missing or wrong, I'm using V.S. 2005, VB.NET 2.0, and I.E. 7.

<meta http-equiv="content-type" content="text/html; charset=windows-1252">

<head>
    <meta http-equiv="content-type" content="text/html; charset=windows-1252">

    <script language="JavaScript">
    function TriggeredKey(e)
    {
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        if (window.event.keyCode = 13 ) return false;
    }
    </script>
</head>
<body onkeydown="TriggeredKey(this)">


推荐答案

如果你有jQuery,试试这个:

If you have jQuery, try this:

$('html').bind('keypress', function(e)
{
   if(e.keyCode == 13)
   {
      return false;
   }
});

这篇关于禁用键盘&lt; enter&gt;键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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