onclick=" cal(prompt('请输入第一个键盘按键字母:'),prompt('请输入第二个键盘按键字母:')) " />
<script type="text/javascript">
function cal(num01,num02){
/*var num11 = parseInt(num01)
var num22 = parseInt(num02)*/
alert(num01)
alert(num02)
}
</script>
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<button id='button'>按一下键盘上的A键试试:)</button>
<script>
$(document).ready(function() {
$('#button').on('click', function() {
alert('由快捷键A触发')
})
$(window).on('keypress', function(e) {
if (e.keyCode === 97) $('#button').trigger('click')
})
})
</script>
</body>
</html>
jquery的trigger用来触发事件。例如$('#button').trigger('click')