输入密钥以保存textarea值

beh*_*d n 3 php jquery ckeditor

嗨我有ckeditor和一个按钮保存cjeditor文本whith ajax.

<textarea id="editor1" name="editor1"></textarea>
<input type="button" name="send" id="send" value="Send" onclick="save()">
Run Code Online (Sandbox Code Playgroud)

我想要删除按钮,当按键输入保存文本whith ajax(运行保存功能)但按下输入ckeditor换行符.以及如何使用输入交换按钮?

<textarea id="editor1" name="editor1"></textarea>
if (enter press in any where web page ) do save();
Run Code Online (Sandbox Code Playgroud)

Alf*_*oML 7

重要的是CKEditor中的内容是iframe,因此尝试检查当前文档上的按键的那些解决方案将失败.

使用CKEditor事件并且不依赖于任何外部库,解决方案就像这样简单:

var editor = CKEDITOR.replace('editor1');  

editor.on('key', function(ev) {
   if (ev.data.keyCode==13)
   {
       ev.cancel();
       console.log('enter');
   }       
});
Run Code Online (Sandbox Code Playgroud)

你可以在这里测试一下:http://jsfiddle.net/zjkSR/ (看看你的控制台)