当前位置:网站首页>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 ');
})
边栏推荐
- MySQL winter vacation self-study 2022 11 (9)
- Déduisez la question d'aujourd'hui - 729. Mon emploi du temps I
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 24
- 论文笔记: 极限多标签学习 GalaXC (暂存, 还没学完)
- High number_ Vector algebra_ Unit vector_ Angle between vector and coordinate axis
- Global and Chinese markets hitting traffic doors 2022-2028: Research Report on technology, participants, trends, market size and share
- [Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 6
- Data preparation
- MySQL (IV) - transactions
- [eight part essay] what is the difference between unrepeatable reading and unreal reading?
猜你喜欢
Minecraft 1.18.1, 1.18.2 module development 22 Sniper rifle
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 22
[robot library] awesome robots Libraries
【无标题】数据库中一条查询SQL执行的过程
Déduisez la question d'aujourd'hui - 729. Mon emploi du temps I
论文笔记: 图神经网络 GAT
Lecture 4 of Data Engineering Series: sample engineering of data centric AI
Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux
Minecraft 1.16.5 biochemical 8 module version 2.0 storybook + more guns
PAT甲级 1033 To Fill or Not to Fill
随机推荐
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 12
Paper notes: limit multi label learning galaxc (temporarily stored, not finished)
RDD partition rules of spark
好用的 JS 脚本
[coppeliasim] efficient conveyor belt
Redis installation
Use Scrollview and tabhost to realize vertical scrollbars and tabs
Compact lidar global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
Httprunnermanager installation (III) - configuring myql Database & initialization data under Linux
729. My schedule I / offer II 106 Bipartite graph
Multi function event recorder of the 5th National Games of the Blue Bridge Cup
Have a look at this generation
[Yunju entrepreneurial foundation notes] Chapter II entrepreneur test 17
零基础自学STM32-野火——GPIO复习篇——使用绝对地址操作GPIO
RDD creation method of spark
Method of changing object properties
The third level of C language punch in
大厂镜像库
Déduisez la question d'aujourd'hui - 729. Mon emploi du temps I
2022 edition illustrated network pdf