-
Notifications
You must be signed in to change notification settings - Fork 2
/
demo.html
118 lines (97 loc) · 4.55 KB
/
demo.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title>hot-key Demo</title>
<script src="../platform/platform.js"></script>
<link rel="import" href="hot-key.html">
</head>
<body unresolved>
<polymer-element name="demo-app">
<template>
<style>
@import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,700,500italic,900,700italic,900italic);
*{ font-family: 'Roboto', sans-serif; line-height:1.2; vertical-align:middle; }
/**
* KEYS.css
*
* A simple stylesheet for rendering beautiful keyboard-style elements.
*
* Author: Michael Hüneburg
* Website: http://michaelhue.com/keyscss
* License: MIT License (see LICENSE.txt)
*/
kbd, .key {
display: inline;
display: inline-block;
min-width: 1em;
padding: .2em .3em;
font: normal .85em/1 "Lucida Grande", Lucida, Arial, sans-serif;
text-align: center;
text-decoration: none;
-moz-border-radius: .3em;
-webkit-border-radius: .3em;
border-radius: .3em;
border: none;
cursor: default;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
}
kbd[title], .key[title] {
cursor: help;
}
/* Dark style for display on light background. This is the default style. */
kbd, kbd.dark, .dark-keys kbd, .key, .key.dark, .dark-keys .key {
background: rgb(80, 80, 80);
background: -moz-linear-gradient(top, rgb(60, 60, 60), rgb(80, 80, 80));
background: -webkit-gradient(linear, left top, left bottom, from(rgb(60, 60, 60)), to(rgb(80, 80, 80)));
color: rgb(250, 250, 250);
text-shadow: -1px -1px 0 rgb(70, 70, 70);
-moz-box-shadow: inset 0 0 1px rgb(150, 150, 150), inset 0 -.05em .4em rgb(80, 80, 80), 0 .1em 0 rgb(30, 30, 30), 0 .1em .1em rgba(0, 0, 0, .3);
-webkit-box-shadow: inset 0 0 1px rgb(150, 150, 150), inset 0 -.05em .4em rgb(80, 80, 80), 0 .1em 0 rgb(30, 30, 30), 0 .1em .1em rgba(0, 0, 0, .3);
box-shadow: inset 0 0 1px rgb(150, 150, 150), inset 0 -.05em .4em rgb(80, 80, 80), 0 .1em 0 rgb(30, 30, 30), 0 .1em .1em rgba(0, 0, 0, .3);
}
/* Light style for display on dark background. */
kbd.light, .light-keys kbd, .key.light, .light-keys .key {
background: rgb(250, 250, 250);
background: -moz-linear-gradient(top, rgb(210, 210, 210), rgb(255, 255, 255));
background: -webkit-gradient(linear, left top, left bottom, from(rgb(210, 210, 210)), to(rgb(255, 255, 255)));
color: rgb(50, 50, 50);
text-shadow: 0 0 2px rgb(255, 255, 255);
-moz-box-shadow: inset 0 0 1px rgb(255, 255, 255), inset 0 0 .4em rgb(200, 200, 200), 0 .1em 0 rgb(130, 130, 130), 0 .11em 0 rgba(0, 0, 0, .4), 0 .1em .11em rgba(0, 0, 0, .9);
-webkit-box-shadow: inset 0 0 1px rgb(255, 255, 255), inset 0 0 .4em rgb(200, 200, 200), 0 .1em 0 rgb(130, 130, 130), 0 .11em 0 rgba(0, 0, 0, .4), 0 .1em .11em rgba(0, 0, 0, .9);
box-shadow: inset 0 0 1px rgb(255, 255, 255), inset 0 0 .4em rgb(200, 200, 200), 0 .1em 0 rgb(130, 130, 130), 0 .11em 0 rgba(0, 0, 0, .4), 0 .1em .11em rgba(0, 0, 0, .9);
}
</style>
<label>Enable shortcuts: </label><input type="checkbox" checked="{{active}}" /><br />
<p>
Hit <kbd>?</kbd> or <kbd>meta</kbd> + <kbd>i</kbd> to fire the help event.
<hot-key shortcut="['?', 'meta+i']" trigger="help" if="{{active}}"></hot-key>
</p>
<p>
Hit the keys <kbd>↑</kbd> <kbd>↑</kbd> <kbd>↓</kbd> <kbd>↓</kbd> <kbd>←</kbd> <kbd>→</kbd> <kbd>←</kbd> <kbd>→</kbd> <kbd>B</kbd> <kbd>A</kbd> in sequence, to trigger the konami code.
<hot-key shortcut="up up down down left right left right b a" trigger="konami" if="{{active}}"></hot-key>
</p>
<div>Log:</div>
<textarea rows="200" cols="100">{{ log }}</textarea>
</template>
<script>
Polymer('demo-app', {
active : true,
log : '',
ready : function(){
this.active = this.active || true;
this.addEventListener('help', function(e){
this.log += 'Help event detected\n';
}.bind(this));
this.addEventListener('konami', function(e){
this.log += 'Konami event detected\n';
}.bind(this));
}
});
</script>
</polymer-element>
<demo-app></demo-app>
</body>
</html>