Skip to content

Instantly share code, notes, and snippets.

@bionicpill
Last active December 17, 2015 10:19
Show Gist options
  • Save bionicpill/5593785 to your computer and use it in GitHub Desktop.
Save bionicpill/5593785 to your computer and use it in GitHub Desktop.
Make ⌘-Enter submit tweets in Twitter.
DotJs = {
is_command_pressed : false,
is_command_key : function (event) {
return (event.which === 91 || event.which === 93);
}
};
$(document).
on("keydown", function(event) {
if (DotJs.is_command_key(event)) {
DotJs.is_command_pressed = true; }
}).
on("keyup", function (event) {
if (DotJs.is_command_key(event)) {
DotJs.is_command_pressed = false; }
}).
on("keydown", function (event) {
if (event.which === 13 && DotJs.is_command_pressed) {
$(event.target).parents(".tweet-form").find('.tweet-action').click();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment