i'm currently developing a web application and i encounter a problem.
As you might know or not, chrome has a feature that gives <input>
(especially text inputs) an "undo" function when you hit CTRL+Z and "redo" with CTRL+Y it may seem like a good feature in normal websites, but currently i'm making an image editor that also uses those keyboard shortcuts (CTRL+Z & CTRL+Y).
in my app i also have a text input, so when i change the text input's content and then hit CTRL+Z to undo the changes in my image editor, it would undo the change in the text editor instead!
这里有一个Codepen http://codepen.io/anandhiya23/full/LRzpWE/这将证明效果
(说明在 Codepen 中)
所以总而言之,我想删除 chrome 中的撤消/重做功能,我该怎么做?
您可以使用 onkeydown 事件和 PreventDefault .. 例如。
document.onkeydown = function(e) {
if (e.ctrlKey && e.key === 'z') {
e.preventDefault();
alert("CTRL + Z!");
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)