-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
70 lines (60 loc) · 1.68 KB
/
index.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
68
69
70
<head>
<script src="https://abusaadp.github.io//js-spatial-navigation/spatial_navigation.js"></script>
<script>
window.addEventListener('load', function() {
// Initialize
SpatialNavigation.init();
// Define navigable elements (anchors and elements with "focusable" class).
SpatialNavigation.add({
selector: 'a, .focusable, button'
});
// Make the *currently existing* navigable elements focusable.
SpatialNavigation.makeFocusable();
// Focus the first navigable element.
SpatialNavigation.focus();
});
</script>
<style>
/* Add style to the focused elements */
:focus {
outline: none;
}
</style>
</head>
<script>
function up(){
console.log("up");
SpatialNavigation.move("up");
SpatialNavigation.focus();
}
function down(){
console.log("down");
SpatialNavigation.move("down");
SpatialNavigation.focus();
}
function right(){
console.log("right");
SpatialNavigation.move("right");
SpatialNavigation.focus();
}
function left(){
console.log("left");
SpatialNavigation.move("left");
SpatialNavigation.focus();
}
function enter(){
console.log("enter");
SpatialNavigation.enterCustom();
}
</script>
<body>
<a href=https://www.google.com />Link 1</a>
<a href="#index">Link 2</a>
<div class="focusable">Div 1</div>
<div class="focusable">Div 2</div>
<button type="button" onclick="up()">Up</button>
<button type="button" onclick="down()">Down</button>
<button type="button" onclick="right()">Right</button>
<button type="button" onclick="left()">Left</button>
<button type="button" onclick="enter()">Enter</button>
</body>