我正在使用 CodeMirror 进行代码编辑,当我按下 INS(插入键)时,它的行为就像在任何普通文本编辑器中一样,在改写和插入模式之间切换,但我不希望这样。
我希望它像正常情况一样 <textarea>
, 实际上没有任何变化。
我能以某种方式做到吗?
最佳答案
我没有用过CodeMirror,但是文档中有一个函数可以切换覆盖/正常插入模式 ( https://codemirror.net/doc/manual.html#usage ):
cm.toggleOverwrite(?value: boolean)
Switches between overwrite and normal insert mode (when not given an argument), or sets the overwrite mode to a specific state (when given an argument).
您可以监听用户按下 insert
键并覆盖传递给该函数的值以使其保持正常插入模式。
关于javascript - 如何禁用 CodeMirror 中的默认插入键行为?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39355215/