当前位置:网站首页>Follow the mouse's angle and keyboard events
Follow the mouse's angle and keyboard events
2022-07-06 02:31:00 【MyDreamingCode】
One 、 Follow the mouse angel
1. e.clientX e.clientY: Coordinates relative to the viewable area of the browser window
2. e.pageX e.pageY: Coordinates relative to the document page
3. e.screenX e.screenY: Coordinates relative to the computer screen
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
height: 2000px;
}
div {
position: absolute;
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
background-color: pink;
}
</style>
</head>
<body>
<div>angel</div>
<script>
var div = document.querySelector('div');
document.addEventListener('mousemove',function(e) {
div.style.top = e.pageY - 50 + 'px';
div.style.left = e.pageX - 50 + 'px';
})
</script>
</body>
</html>
Two 、 Keyboard events
1. keyup: The keyboard bounced up
document.addEventListener('keyup',function() {
console.log(' The keyboard bounced up ');
})
2. keydown: Press the keyboard
document.addEventListener('keydown',function() {
console.log(' Press the keyboard ');
})
3. keypress: Press the keyboard ( Inside keyCode Case sensitive ASCII value , But the function key is not recognized )
document.addEventListener('keypress',function() {
console.log(' Press the keyboard ');
})
边栏推荐
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
- Y a - t - il des cas où sqlcdc surveille plusieurs tables et les associe à une autre? Tout fonctionne dans MySQL
- MySQL (IV) - transactions
- 【coppeliasim】6自由度路径规划
- 高数_向量代数_单位向量_向量与坐标轴的夹角
- 数据准备工作
- Lecture 4 of Data Engineering Series: sample engineering of data centric AI
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 21
- 米家、涂鸦、Hilink、智汀等生态哪家强?5大主流智能品牌分析
猜你喜欢
Use image components to slide through photo albums and mobile phone photo album pages
3D drawing ()
Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux
Building the prototype of library functions -- refer to the manual of wildfire
vs code保存时 出现两次格式化
0211 embedded C language learning
Reset nodejs of the system
Audio and video engineer YUV and RGB detailed explanation
Shell脚本更新存储过程到数据库
HttpRunnerManager安装(三)-Linux下配置myql数据库&初始化数据
随机推荐
Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux
Crawler (9) - scrape framework (1) | scrape asynchronous web crawler framework
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 9
[postgraduate entrance examination English] prepare for 2023, learn list5 words
How to check the lock information in gbase 8C database?
【机器人库】 awesome-robotics-libraries
Number conclusion LC skimming review - 1
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
Minecraft 1.16.5 生化8 模组 2.0版本 故事书+更多枪械
550 permission denied occurs when FTP uploads files, which is not a user permission problem
Overview of spark RDD
Audio and video engineer YUV and RGB detailed explanation
我把驱动换成了5.1.35,但是还是一样的错误,我现在是能连成功,但是我每做一次sql操作都会报这个
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
2022年版图解网络PDF
2022.02.13
在GBase 8c数据库中使用自带工具检查健康状态时,需要注意什么?
论文笔记: 极限多标签学习 GalaXC (暂存, 还没学完)
高数_向量代数_单位向量_向量与坐标轴的夹角
Multiple solutions to one problem, asp Net core application startup initialization n schemes [Part 1]