Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2017 11:32
Show Gist options
  • Save anonymous/f336b25058855e436d0f5b7df22850df to your computer and use it in GitHub Desktop.
Save anonymous/f336b25058855e436d0f5b7df22850df to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/xajipev
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="http://cdn.rawgit.com/dmauro/Keypress/master/keypress.js"></script>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
</head>
<body>
<p>Check out console to see log</p>
<button class="register-meta-combo">
REGISTER META COMBO
</button>
<button class="register-ctrl-combo">
REGISTER CTRL COMBO
</button>
<hr>
<button class="unregister-meta-combo">
UNREGISTER META COMBO
</button>
<button class="unregister-ctrl-combo">
UNREGISTER CTRL COMBO
</button>
<script id="jsbin-javascript">
this.listener = new window.keypress.Listener();
$('.register-meta-combo').click(() => {
console.log('register-meta-combo - meta c');
this.listener.register_combo({
keys: "meta c",
is_solitary: true,
on_keydown: () => {
console.log('meta c pressed');
},
});
})
$('.register-ctrl-combo').click(() => {
console.log('register-ctrl-combo - ctrl v');
this.listener.register_combo({
keys: "ctrl v",
is_solitary: true,
on_keydown: () => {
console.log('ctrl v pressed');
},
});
})
$('.unregister-meta-combo').click(() => {
console.log('unregister-meta-combo - meta c');
this.listener.unregister_combo('meta c');
})
$('.unregister-ctrl-combo').click(() => {
console.log('unregister-ctrl-combo - ctrl v');
this.listener.unregister_combo('ctrl v');
})
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="//cdn.rawgit.com/dmauro/Keypress/master/keypress.js"><\/script>
<script src="https://code.jquery.com/jquery-3.1.0.js"><\/script>
</head>
<body>
<p>Check out console to see log</p>
<button class="register-meta-combo">
REGISTER META COMBO
</button>
<button class="register-ctrl-combo">
REGISTER CTRL COMBO
</button>
<hr>
<button class="unregister-meta-combo">
UNREGISTER META COMBO
</button>
<button class="unregister-ctrl-combo">
UNREGISTER CTRL COMBO
</button>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">this.listener = new window.keypress.Listener();
$('.register-meta-combo').click(() => {
console.log('register-meta-combo - meta c');
this.listener.register_combo({
keys: "meta c",
is_solitary: true,
on_keydown: () => {
console.log('meta c pressed');
},
});
})
$('.register-ctrl-combo').click(() => {
console.log('register-ctrl-combo - ctrl v');
this.listener.register_combo({
keys: "ctrl v",
is_solitary: true,
on_keydown: () => {
console.log('ctrl v pressed');
},
});
})
$('.unregister-meta-combo').click(() => {
console.log('unregister-meta-combo - meta c');
this.listener.unregister_combo('meta c');
})
$('.unregister-ctrl-combo').click(() => {
console.log('unregister-ctrl-combo - ctrl v');
this.listener.unregister_combo('ctrl v');
})</script></body>
</html>
this.listener = new window.keypress.Listener();
$('.register-meta-combo').click(() => {
console.log('register-meta-combo - meta c');
this.listener.register_combo({
keys: "meta c",
is_solitary: true,
on_keydown: () => {
console.log('meta c pressed');
},
});
})
$('.register-ctrl-combo').click(() => {
console.log('register-ctrl-combo - ctrl v');
this.listener.register_combo({
keys: "ctrl v",
is_solitary: true,
on_keydown: () => {
console.log('ctrl v pressed');
},
});
})
$('.unregister-meta-combo').click(() => {
console.log('unregister-meta-combo - meta c');
this.listener.unregister_combo('meta c');
})
$('.unregister-ctrl-combo').click(() => {
console.log('unregister-ctrl-combo - ctrl v');
this.listener.unregister_combo('ctrl v');
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment