Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated examples

  • Loading branch information...
commit ce1d7072775175011e242c4cfba2469e5ac4c9e8 1 parent f8ad7bc
@datapimp authored
View
9 README.md
@@ -9,9 +9,12 @@ I use this library to embed small single purpose javascript widgets and applicat
An example: as an app which takes a screenshot of the current webpage with a bug on it, and submits a github issue with that data.
```coffeescript
-# Whenever the user types the word 'sync' in a non text input
-KeyLauncher.onSequence "sync", ()->
- alert 'sync sequence detected'
+# Whenever the user types the word 'shake' in a non text input
+KeyLauncher.onSequence "shake", ()->
+ $('body').html '<iframe width="560" height="315" src="http://www.youtube.com/embed/3R8HGsbI4QY" frameborder="0" allowfullscreen></iframe>'
+, requires:[
+ "//cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js",
+]
# Basic delegate to keymaster
KeyLauncher.on "shift+command+j", ()->
View
2  source/index.html.haml
@@ -1,5 +1,5 @@
%h1 KeyLauncher.js
%ul
%li command + j will launch a special command with external dependencies
- %li typing the word 'sync' will do something
+ %li typing the word 'shake' will do something
%li shift + command + j is a basic key command
View
13 source/javascripts/example.coffee
@@ -1,13 +1,16 @@
-# Whenever the user types the word 'sync' in a non text input
-KeyLauncher.onSequence "sync", ()->
- alert 'sync sequence detected'
+# Type the word shake
+KeyLauncher.onSequence "shake", ()->
+ $('body').html '<iframe width="560" height="315" src="http://www.youtube.com/embed/3R8HGsbI4QY" frameborder="0" allowfullscreen></iframe>'
+, requires:[
+ "//cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js",
+]
# Basic delegate to keymaster
KeyLauncher.on "shift+command+j", ()->
alert 'normal key commands work too'
# Specify dependencies to load before running the command
-window.requiresLauncher = KeyLauncher.on "command+j", ()->
+KeyLauncher.on "command+j", ()->
if _.isObject(Backbone)
$('body').append "We loaded underscore, backbone, and zepto"
@@ -15,4 +18,4 @@ window.requiresLauncher = KeyLauncher.on "command+j", ()->
"//cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js",
"//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js",
"//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min.js"
-]
+]
Please sign in to comment.
Something went wrong with that request. Please try again.