提交 7dab4b44 编写于 作者: I ikikko

handling shortcut key only when firing 'keydown' event

上级 7360f45d
......@@ -70,6 +70,9 @@ THE SOFTWARE.
function isCommandKey() {
return isGeckoCommandKey() || isOperaCommandKey() || isWebKitCommandKey();
}
function isReturnKeyDown() {
return event.type == 'keydown' && event.keyCode == Event.KEY_RETURN;
}
function saveAndSubmit() {
editor.save();
document.form1.submit();
......@@ -84,14 +87,14 @@ THE SOFTWARE.
if (event.type == 'keyup' && isCommandKey()) {
cmdKeyDown = false;
}
if (cmdKeyDown && event.keyCode == Event.KEY_RETURN) {
if (cmdKeyDown && isReturnKeyDown()) {
saveAndSubmit();
return true;
}
// Windows, Linux (Ctrl + Enter)
} else {
if (event.ctrlKey && event.keyCode == Event.KEY_RETURN) {
if (event.ctrlKey && isReturnKeyDown()) {
saveAndSubmit();
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册