Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
85 lines (69 sloc) 2.35 KB
<title>The Keymaster</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<script src="keymaster.js"></script>
The Keymaster
<input type="text" placeholder="a text input"/>
<textarea placeholder="a textarea"></textarea>
<li>Press 'c'. Nothing should be logged on console.</li>
<li>Press 'o' or Enter or Cursor &larr;. Console should log function call.</li>
<li>Press 'i'. Switches scope to 'issues'.</li>
<li>Press 'c'. Console should log function call.</li>
<li>Press 'o' or Enter or Cursor &larr;. Console should log function call.</li>
At any time, try pressing ⌘+right, shift+left or ctrl+shift+alt+d.
When a input, a select or a textarea element is focused, key inputs should be ignored.
key('c', 'issues', function(){
key('command+r, ctrl+r', 'issues', function(){
console.log('Hijacked Command+R or Ctrl+R, damn!');
return false;
key('i', function(){
console.log('Switched to "issues" scope. Command+R or Ctrl+R is now no longer reloading...');
key('i', function(){
console.log('(example of multiple assignment)');
key('o, enter, left', function(){
console.log('o, enter or left pressed!');
key('ctrl+c', function(){
console.log('this is not the command line');
key('⌘+right,shift+left,ctrl+shift+alt+d', function(event){
console.log('command+right, or shift+left, or ctrl+shift+alt+d');
console.log('here is the event: ', event);
console.log('key.control', key.control);
console.log('key.ctrl', key.ctrl);
console.log('key.shift', key.shift);
console.log('key.alt', key.alt);
console.log('key["⌘"]', key[""]);
return false; // prevent default && stop propagation
key('⌘+x, ctrl+x', function(event, handler){
console.log(handler.shortcut, handler.scope);
return false;
key('/', function(){ console.log('/') });
key('shift+]', function(){ console.log('shift+]') });
// document.onkeydown = function(event){
// console.log(event.keyCode);
// }
Jump to Line
Something went wrong with that request. Please try again.