Skip to content

Instantly share code, notes, and snippets.

@jordanfbrown
Created December 10, 2011 00:25
Show Gist options
  • Save jordanfbrown/1453974 to your computer and use it in GitHub Desktop.
Save jordanfbrown/1453974 to your computer and use it in GitHub Desktop.
Bind spacebar to play/pause on soundcloud
(function($) {
var $currentPlayButton = $();
$(document).bind('keydown', function(e) {
if(e.which === 32) {
if(!$(document.activeElement).is('input')) {
e.preventDefault();
if($currentPlayButton.length > 0) {
$currentPlayButton.click();
}
}
}
});
$('a.play').bind('click', function(e) {
$currentPlayButton = $(e.currentTarget);
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment