我正在尝试使用组合键 alt+i 创建一个快捷方式,通常情况下会输入一个代表重音符的按键 ˆ,我尝试了以下方法:
$(document).ready(function () {
$("#txtInput").keydown(
function (event) {
if (event.which == 229 && event.altKey === true) {
alert(event);
event.preventDefault();
event.stopPropagation();
}
}
);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<input id="txtInput" type="text" />
"#txtInput"
中。
有没有办法防止这段文本被输入?