Skip to content

Instantly share code, notes, and snippets.

@sebastiangeiger
Created October 8, 2014 12:01
Show Gist options
  • Save sebastiangeiger/69b9c3ca7b44a5b74a1a to your computer and use it in GitHub Desktop.
Save sebastiangeiger/69b9c3ca7b44a5b74a1a to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<!--
Created using JS Bin
http://jsbin.com
Copyright (c) 2014 by sebastiangeiger (http://jsbin.com/cutiv/7/edit)
Released under the MIT license: http://jsbin.mit-license.org
-->
<html>
<head>
<meta charset="utf-8">
<title>Ember Starter Kit</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="http://builds.emberjs.com/tags/v1.7.0/ember.js"></script>
<style id="jsbin-css">
/* Put your CSS here */
html, body {
margin: 20px;
}
</style>
</head>
<body>
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<h3>Key pressed: {{lastKeyPressed}}</h3>
<ul>
{{#each item in model}}
<li>{{item}}</li>
{{/each}}
</ul>
</script>
<script id="jsbin-javascript">
App = Ember.Application.create();
App.Router.map(function() {});
App.IndexRoute = Ember.Route.extend({
model: function() {
return ['red', 'yellow', 'blue'];
},
setupController: function(controller,model){
this._super(controller, model);
Ember.Instrumentation.subscribe('globalKeys.keypressed', {
before: function(eventName,time,payload) {
controller.set('lastKeyPressed', payload);
},
after: function() {}
})
},
});
App.IndexController = Ember.ObjectController.extend({
lastKeyPressed: 'none'
});
$(document).keypress(function(e) {
Ember.Instrumentation.instrument('globalKeys.keypressed', e.keyCode, function(){});
console.log(e.keyCode);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment