F2的按键无法直接使用 [英] Keypress for F2 not directly working

查看:135
本文介绍了F2的按键无法直接使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

当我按下"F2"时,文本框中的按键事件代码为

Hi every one,

My code for keypress event on textbox, when I press ''F2''

<script language="javascript">
document.onkeyup = KeyCheck;
function KeyCheck(e)
{   
   var KeyID = (window.event) ? event.keyCode : e.keyCode;   
   if(KeyID == 113)   
   {
      alert("hi");   
   }
}</script>



但是问题是,在F2之前,我必须按其他任何键.如果我直接按F2键,它将无法正常工作.可能是什么原因.保留一些代码,以便在我直接按F2键时起作用.



but the problem is, before F2 i have to press any other key. If i directly press on F2 its not working. What could be the reason. Sujjest some code so that it work if i directly press F2 key

推荐答案

,因为您的第一次按键确定了焦点所在?

为什么您想让F2在Web应用程序中正常工作?我从未见过这样做并推动F2对我来说永远不会发生.
because your first keypress establishes the focus where you want it to be ?

Why would you want F2 to work in a web app anyhow ? I''ve never seen that done and pushing F2 would never occur to me.


>一篇旧文章,但我觉得应该得到一个答案&使用原因!!

我使用它将访问者发送到搜索页面,在我的一个客户站点的其他部分,f10用于保存当前表单-因此它确实有其用途.

只需使用 body onload事件将焦点设置为表单的第一个字段,然后按键就可以正常工作了.

格伦
西班牙
>An old post, but one I feel deserves an answer & reason for using!!

I use it to send a visitor to the search page, and in other parts of one of my client sites, f10 is used to save the current form - so it does have its uses.

Just set focus to the first field on your form using a body onload event - then the keypress works perfectly.

Glen
Spain


这篇关于F2的按键无法直接使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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