Created
December 10, 2011 00:25
-
-
Save jordanfbrown/1453974 to your computer and use it in GitHub Desktop.
Bind spacebar to play/pause on soundcloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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