https://github.com/dewski/cmd-enter
Every textarea should let you submit comments by pressing cmd-enter or ctrl-enter. For every site that doesn't support it, a kitten weeps. Here's to making less kittens weep.
https://github.com/dewski/cmd-enter
Last synced: 9 months ago
JSON representation
Every textarea should let you submit comments by pressing cmd-enter or ctrl-enter. For every site that doesn't support it, a kitten weeps. Here's to making less kittens weep.
- Host: GitHub
- URL: https://github.com/dewski/cmd-enter
- Owner: dewski
- Created: 2013-01-30T21:50:59.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-01-31T00:48:28.000Z (about 13 years ago)
- Last Synced: 2025-06-20T23:09:00.213Z (9 months ago)
- Language: JavaScript
- Homepage:
- Size: 134 KB
- Stars: 36
- Watchers: 3
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# cmd-enter
Every textarea should let you submit comments by pressing cmd-enter or
ctrl-enter. For every site that doesn't support it, a kitten weeps. Here's
to making less kittens weep.
## Requirements
- [dotjs](https://github.com/defunkt/dotjs)
## Supported Sites
- [dribbble](https://github.com/dewski/cmd-enter/blob/master/dribbble.com.js)
- [hackernews](https://github.com/dewski/cmd-enter/blob/master/news.ycombinator.com.js)
- [reddit](https://github.com/dewski/cmd-enter/blob/master/reddit.com.js)
- [twitter](https://github.com/dewski/cmd-enter/blob/master/twitter.com.js)
- [stackoverflow](https://github.com/dewski/cmd-enter/blob/master/stackoverflow.com.js)
## Contributing
If reddit.com is giving you a bad time and not letting you use cmd-enter
to submit comments, just create a reddit.js.com file and add the JavaScript
required to submit comments (example below). jQuery is available from dotjs
regardless if the target site has it or not. Some sites may require multiple
event listeners if they format their textareas differently throughout their
site.
Here is an example of adding cmd-enter to reddit.com:
```js
$(document).on('keydown', '.usertext-edit textarea', function(e) {
if(e.keyCode == 13 && (e.metaKey || e.ctrlKey)) {
$(this).parents('form').submit()
}
})
```
Hints:
- `.usertext-edit textarea` is the selector for all textareas we are listening to.
- `e.keyCode == 13` - 13 here is the enter key.
- `(e.metaKey || e.ctrlKey)` is either the command key or ctrl key.
## Note on Patches/Pull Requests
- Fork the project.
- Add the cmd-enter behavior to a site.
- Add the site to the [Supported Sites](https://github.com/dewski/cmd-enter#supported-sites) part of this README.
- Send me a pull request.