Skip to content

Instantly share code, notes, and snippets.

@RudolfVonKrugstein
Created July 16, 2012 11:20
Show Gist options
  • Save RudolfVonKrugstein/3122201 to your computer and use it in GitHub Desktop.
Save RudolfVonKrugstein/3122201 to your computer and use it in GitHub Desktop.
Callbacks in haste
function jsSetInterval(msecs, cb, _) {
window.setInterval(function() {A(cb,[0]);}, msecs);
return [1,0];
}
function jsSetOnKeyDown(cb, _) {
window.addEventListener('keydown', function(e) {A(cb,[[1,parseInt(e.keyCode)],0]);}, true);
return [1,0];
}
function jsSetOnKeyUp(cb, _) {
window.addEventListener('keyup', function(e) {A(cb,[[1,parseInt(e.keyCode)],0]);}, true);
return [1,0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment