我有一个快捷键K,它应该会聚焦在我的输入框上,但我不想在聚焦时插入字母K
。
$(document).keydown(function(event) {
if (event.which == 75) {
$('input').focus();
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<input type="text">
event.preventDefault();
- Johannes Jander