keyboard - How to catch global keyPress events in Ember -


i'm sure i'm missing obvious, but: how respond keypress event anywhere on page?

for example, had video player , wanted pause if user pressed spacebar @ point. or, i'm writing game , want arrow keys direct character, without regard specific views or subviews.

defining app.applicationview = ember.view.create({ keypress: whatever }) doesn't seem work. have thought keypress events bubble that.

i guess want is:

$(document).keypress(function(e) {     alert('you pressed key!'); }); 

except through ember.

if looking global keypress code example above best solution. ember application attached body (or root element you've defined) , require sort of focus on view. example do:

app.applicationview = em.view.extend({   keyup: function(){     alert(1);   } }); 

this work, application view or child need have focus. useful, example, if wanted capture key event of input fields.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -