当前位置:网站首页>13. What is the difference between onkeydown, up and onkeypress?
13. What is the difference between onkeydown, up and onkeypress?
2022-07-24 18:21:00 【yingxingyf】
onkeydown,up and onkeypress The difference between ?
1、 Distinguish from the triggered key
onkeydown and onkeyup Works for all keys
onkeypress Works for keys related to editing ( Such as : Alphabetic key , The backspace key can trigger this event , But press shift,ctrl Key will not trigger this event )2、keyCode It means different
keyCode Attribute meaning :
stay keydown and keyup In the incident ,keyCode Attribute represents the virtual code of the keyboard ( Unique encoding for each key , It has nothing to do with case )
stay keypress In the incident ,keyCode Attribute means keyboard unicode code (ASCII code )
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title> Simple calendar </title>
<style type="text/css">
</style>
</head>
<body>
<input id="txt" type="text" />
<input id="btn01" type="button" value=" test 01" />
</body>
</html>
<script type="text/javascript">
//onkeydown,up and onkeypress The difference between
//1、 Distinguish from the triggered key
//
// onkeydown and onkeyup Works for all keys
// onkeypress Works for keys related to editing ( Such as : Alphabetic key , The backspace key can trigger this event , But press shift,ctrl Key will not trigger this event )
//2、keyCode It means different
//keyCode Attribute meaning :
// stay keydown and keyup In the incident ,keyCode Attribute represents the virtual code of the keyboard ( Unique encoding for each key , It has nothing to do with case )
// stay keypress In the incident ,keyCode Attribute means keyboard unicode code (ASCII code )
window.onload=function(){
//onkeydown: Press down
/*
$("txt").onkeydown = function(event){
var evt = event || window.event;
console.log(evt.keyCode);// stay keydown and keyup In the incident ,keyCode Attribute represents the virtual code of the keyboard ( Unique encoding for each key )
}
*/
/*onkeyup: Spring up
$("txt").onkeyup = function(event){
var evt = event || window.event;
console.log(evt.keyCode);// stay keydown and keyup In the incident ,keyCode Attribute represents the virtual code of the keyboard ( Unique encoding for each key )
}
*/
//onkeypress: Press and bounce
$("txt").onkeypress = function(event){
var evt = event || window.event;
console.log(evt.keyCode);// stay keypress In the incident ,keyCode Attribute means keyboard unicode code (ASCII code )
}
}
function $(id){
return document.getElementById(id);
}
</script>
边栏推荐
- Section 11 cache avalanche, hot data failure follow Daewoo redis ------- directory post
- Growth of operation and maintenance Xiaobai - week 8 of Architecture
- Laravel notes - RSA encryption of user login password (improve system security)
- CF Lomsat gelral(启发式合并)
- odoo中的bom理解
- [OBS] dependency Library: x264 vs Build
- jmeter -- prometheus+grafana服务器性能可视化
- 0625~<config>-<bus>
- Mac database management software Navicat premium essentials mac
- How to solve the problem that yaml in idea is unrecognized or red?
猜你喜欢

Mozilla foundation released 2022 Internet health report: AI will contribute 15.7 trillion yuan to the global economy in 2030, and the investment in AI in the United States last year was nearly three t

Flink operation Hudi data table

Pycharm configuring opencv Library

web渗透经验汇总ing

Wechat applet

PXE efficient batch network installation
Go to bed capacity exchange

Install jumpserver
去不图床容量兑换

安装JumpServer
随机推荐
【校验】只能输入数字(正负数)
redis集群的三种方式
Problems needing attention in writing pages
XSS bypass pose summary
In depth analysis of the famous Alibaba cloud log4j vulnerability
Alibaba /1688 API instructions for searching products by map (pailitao)
Emerging potential of interactive virtual reality technology in drug discovery
JS array method sort() collation parsing
Cookies and session "suggestions collection"
Sword finger offer 21. adjust the array order so that odd numbers precede even numbers
Section 10 cache breakdown follow Daewoo redis ------- directory post
Example of single table query in ORM student management system
Namespace:集群环境共享与隔离
0614~ holiday self study
如何为超级通胀做好准备
根证书的有效期与服务器SSL证书一样长吗?
怎么解决idea中yaml无法识别或者飘红?
[verification] only numbers (positive and negative numbers) can be entered
Custom web framework
Simulation implementation vector