如何在jquery中检测F5刷新按键事件? [英] how to detect an F5 refresh keypress event in jquery?

查看:432
本文介绍了如何在jquery中检测F5刷新按键事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到jquery有一个按键功能。但它似乎只能检测数字和字符的按键事件。它无法检测到F5按键事件。最令我惊讶的是网上的每个人都说F5的keyCode是116,但是当我使用jquery按键功能时,它只显示字符t的keyCode为116(似乎116是小写的ascii代码) T)!有人可以告诉我这个以及如何在javascript或jquery中检测F5事件吗?非常感谢提前。

I noticed that jquery has a keypress function. But it seems that it can only detect keypress event of numbers and characters. It cannot detect the F5 keypress event. And What surprises me the most is everyone online says that the keyCode of F5 is 116, But when I use the jquery keypress function, it just shows that the character t has the keyCode of 116(it seems that 116 is the ascii code of lowercase t)! Can somebody give me any idea about this and how to detect the F5 event in javascript or jquery? Thanks so much in advance.

推荐答案

按键事件不接受功能键(F1-F12)。您可以尝试使用keydown事件。

The keypress event does not accept function keys(F1-F12). You can try to use keydown event.

这篇关于如何在jquery中检测F5刷新按键事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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