当前位置:网站首页>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 ');
})
边栏推荐
- Overview of spark RDD
- 729. 我的日程安排表 I / 剑指 Offer II 106. 二分图
- Global and Chinese markets hitting traffic doors 2022-2028: Research Report on technology, participants, trends, market size and share
- Initial understanding of pointer variables
- Use image components to slide through photo albums and mobile phone photo album pages
- General process of machine learning training and parameter optimization (discussion)
- SSM assembly
- 2022 China eye Expo, Shandong vision prevention and control exhibition, myopia, China myopia correction Exhibition
- Bigder: I felt good about the 34/100 interview, but I didn't receive the admission
- [postgraduate entrance examination English] prepare for 2023, learn list5 words
猜你喜欢
零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
Use the list component to realize the drop-down list and address list
RDD partition rules of spark
【MySQL 15】Could not increase number of max_open_files to more than 10000 (request: 65535)
高数_向量代数_单位向量_向量与坐标轴的夹角
零基础自学STM32-复习篇2——使用结构体封装GPIO寄存器
技术管理进阶——什么是管理者之体力、脑力、心力
Zero foundation self-study STM32 - Review 2 - encapsulating GPIO registers with structures
[solution] add multiple directories in different parts of the same word document
Multi function event recorder of the 5th National Games of the Blue Bridge Cup
随机推荐
3D drawing ()
Global and Chinese markets of nasal oxygen tubes 2022-2028: Research Report on technology, participants, trends, market size and share
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
会员积分营销系统操作的时候怎样提升消费者的积极性?
Global and Chinese markets hitting traffic doors 2022-2028: Research Report on technology, participants, trends, market size and share
MySQL lethal serial question 1 -- are you familiar with MySQL transactions?
How to generate rich text online
Global and Chinese market of commercial cheese crushers 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
MySQL winter vacation self-study 2022 11 (6)
RDD creation method of spark
Audio and video engineer YUV and RGB detailed explanation
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
【MySQL 15】Could not increase number of max_ open_ files to more than 10000 (request: 65535)
Ue4- how to make a simple TPS role (II) - realize the basic movement of the role
HDU_p1237_简单计算器_stack
零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
Accident index statistics
Zero foundation self-study STM32 - Review 2 - encapsulating GPIO registers with structures
Spark accumulator