短篇小说:
// get the editor instance
var editor = CKEDITOR.instances.editor1;
// this is what I want, but it does not exist
editor.execCommand('delete');
// I've played with this, found somewhere, but without success.
editor.fire('key', { keyCode : 46 } )长篇故事:
在.NET WindowsForms的Webbrowser控件中使用Webbrowser控件时会出现问题。有几个键(包括DELete键)根本没有传播到控件。
我成功地使用了一个全局键盘钩子来拦截键,并将窗口消息直接发送到嵌入式IE窗口句柄,但没有成功。
现在我的目标是模拟javascript中的delete键,因为我可以从我的.NET应用程序中调用一个js函数。无论如何,这必须工作,因为它在虚拟键盘插件内工作。(见示例)
遗憾的是,我无法从插件代码中了解到它是如何工作的。如果有人能寄给我一个工作样本,我会很高兴的。
谢谢!
发布于 2015-10-19 08:49:16
我在javascript虚拟键盘(Jsvk插件)中找到了一个库。
它被称为DocumentSelection,可以找到这里。
<script src="./documentselection.js"></script>
function simulateDelete()
{
var editor = CKEDITOR.instances.editor1;
var container = (editor.container.getElementsByTag('textarea').getItem(0) ||
editor.container.getElementsByTag('iframe').getItem(0)
).$;
DocumentSelection.deleteAtCursor(container, true);
}也许有人有一个更容易的解决方案,而不需要外部的libaray。
发布于 2017-02-13 09:57:25
我想你需要一些线索..。
在那里,is...Check文档
alert( event.getKey() );要获得关键元素,另一个元素是
alert( event.getKeystroke() == 65 );// "a" key
alert( event.getKeystroke() == CKEDITOR.CTRL + 65 );// CTRL + "a" key
alert( event.getKeystroke() == CKEDITOR.CTRL + CKEDITOR.SHIFT + 65 );//CTRL + SHIFT + "a" keyhttps://stackoverflow.com/questions/33201930
复制相似问题