-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path039 tophareket.html
67 lines (62 loc) · 1.9 KB
/
039 tophareket.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#top{
width: 80px;
height: 80px;
border-radius: 40px;
background: linear-gradient(#db15e2, #4b014e);
position: absolute;
left:300px;
top:300px;
}
#bilgi{
width: 200px;
height: 25px;
background-color: navy;
color:#FFF;
position: fixed;
bottom:10px; right: 10px;
text-align: center;
font-size: 15px;
font-weight: bold;
font-family: Tahoma;
padding: 5px;
}
</style>
</head>
<body>
<div id="bilgi"></div>
<div id="top"></div>
<script>
let sol=100;
let ust=100;
document.addEventListener('keydown', function(tus){
if (tus.keyCode==37){
document.getElementById('bilgi').innerText="Sol tuşa basıldı.";
sol-=5;
document.getElementById('top').style.left=sol+'px';
}
if (tus.keyCode==38){
document.getElementById('bilgi').innerText="Yukarı tuşa basıldı.";
ust-=5;
document.getElementById('top').style.top=ust+'px';
}
if (tus.keyCode==39){
document.getElementById('bilgi').innerText="Sağ tuşa basıldı.";
sol+=5;
document.getElementById('top').style.left=sol+'px';
}
if (tus.keyCode==40){
document.getElementById('bilgi').innerText="Aşağı tuşa basıldı.";
ust+=5;
document.getElementById('top').style.top=ust+'px';
}
});
</script>
</body>
</html>