admin管理员组文章数量:1026125
I'm using a keyup detection into all my forms to detect the enter button. This is easy, when you are focused in a form's input if you hit enter and the event keyCode is equal to 13 then the form submitted.
But now I want to detect the Cmd + Enter bination, because when you are focused in a textarea, the enter button is a line break. So how my detect statement should look like?
Thank you
I'm using a keyup detection into all my forms to detect the enter button. This is easy, when you are focused in a form's input if you hit enter and the event keyCode is equal to 13 then the form submitted.
But now I want to detect the Cmd + Enter bination, because when you are focused in a textarea, the enter button is a line break. So how my detect statement should look like?
Thank you
Share Improve this question asked Feb 20, 2012 at 16:09 Andrew KordampalosAndrew Kordampalos 4231 gold badge7 silver badges11 bronze badges1 Answer
Reset to default 6You mean ctrl with Cmd
? Then check if event.ctrlKey
is true:
if (event.ctrlKey && event.keyCode == 13) {
alert('now');
}
Also see this example.
P.s: there are also the booleans event.altKey
for alt, event.shiftKey
for shift and event.metakey
I'm using a keyup detection into all my forms to detect the enter button. This is easy, when you are focused in a form's input if you hit enter and the event keyCode is equal to 13 then the form submitted.
But now I want to detect the Cmd + Enter bination, because when you are focused in a textarea, the enter button is a line break. So how my detect statement should look like?
Thank you
I'm using a keyup detection into all my forms to detect the enter button. This is easy, when you are focused in a form's input if you hit enter and the event keyCode is equal to 13 then the form submitted.
But now I want to detect the Cmd + Enter bination, because when you are focused in a textarea, the enter button is a line break. So how my detect statement should look like?
Thank you
Share Improve this question asked Feb 20, 2012 at 16:09 Andrew KordampalosAndrew Kordampalos 4231 gold badge7 silver badges11 bronze badges1 Answer
Reset to default 6You mean ctrl with Cmd
? Then check if event.ctrlKey
is true:
if (event.ctrlKey && event.keyCode == 13) {
alert('now');
}
Also see this example.
P.s: there are also the booleans event.altKey
for alt, event.shiftKey
for shift and event.metakey
本文标签: onkeyupCmd Enter keyup combination detection using javascriptStack Overflow
版权声明:本文标题:onkeyup - Cmd Enter keyup combination detection using javascript - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745634631a2160370.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论