当前位置:网站首页>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 ');
})
边栏推荐
- 729. My schedule I / offer II 106 Bipartite graph
- 在GBase 8c数据库中使用自带工具检查健康状态时,需要注意什么?
- 2022.02.13
- 构建库函数的雏形——参照野火的手册
- Global and Chinese market of wheelchair climbing machines 2022-2028: Research Report on technology, participants, trends, market size and share
- Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
- 怎么检查GBase 8c数据库中的锁信息?
- 零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
- Multi function event recorder of the 5th National Games of the Blue Bridge Cup
猜你喜欢
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15](/img/72/0fe9cb032339d5f1ccf6f6c24edc57.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 15

Li Kou today's question -729 My schedule I

Reset nodejs of the system

Shell脚本更新存储过程到数据库
![[solution] add multiple directories in different parts of the same word document](/img/22/32e43493ed3b0b42e35ceb9ab5b597.jpg)
[solution] add multiple directories in different parts of the same word document

2022 edition illustrated network pdf
![[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8](/img/16/33f5623625ba817e6e022b5cb7ff5d.jpg)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 8

Easy to use js script

Formatting occurs twice when vs code is saved
![[Digital IC manual tearing code] Verilog asynchronous reset synchronous release | topic | principle | design | simulation](/img/e4/890e84ab8326e029c4915163904d85.jpg)
[Digital IC manual tearing code] Verilog asynchronous reset synchronous release | topic | principle | design | simulation
随机推荐
力扣今日題-729. 我的日程安排錶 I
大厂镜像库
MySQL learning notes - subquery exercise
有没有sqlcdc监控多张表 再关联后 sink到另外一张表的案例啊?全部在 mysql中操作
一题多解,ASP.NET Core应用启动初始化的N种方案[上篇]
机器学习训练与参数优化的一般过程 (讨论)
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 10
我把驱动换成了5.1.35,但是还是一样的错误,我现在是能连成功,但是我每做一次sql操作都会报这个
[coppeliasim] 6-DOF path planning
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 16
Global and Chinese markets for single beam side scan sonar 2022-2028: Research Report on technology, participants, trends, market size and share
Blue Bridge Cup group B provincial preliminaries first question 2013 (Gauss Diary)
剑指 Offer 30. 包含min函数的栈
Prepare for the autumn face-to-face test questions
【coppeliasim】6自由度路径规划
Redis delete policy
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
Spark accumulator
PAT甲级 1033 To Fill or Not to Fill
Li Kou today's question -729 My schedule I