How do I trigger something when the cursor is within TEXTAREA and Ctrl+Enter is pressed? Using jQuery. Thanks
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
Actually this one does the trick and works in all browsers:
link to js fiddle
first you have to set a flag when Ctrl is pressed, do this onkeydown. then you have to check the keydown of enter. unset the flag when you see a keyup for Ctrl.
Universal solution
Supports OS X as well.
I found answers of others either incomplete or not cross-browser compatible.
This code works google chrome.
This can be extended to a simple-but-flexible JQuery plugin as in:
Thus
should submit a form when the user presses ctrl-enter with focus on that form's textarea.
(With thanks to https://stackoverflow.com/a/9964945/1017546)