You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<title>键盘事件</title>
|
|
|
|
<script type="text/javascript" src="../vue.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="root">
|
|
|
|
<h1>你好 {{name}}</h1>
|
|
|
|
<input type="text" placeholder="你动我试试" @keyup.space="showInfo"><br>
|
|
|
|
<input type="text" placeholder="你动我试试" @keyup.caps-lock="showInfo"><br>
|
|
|
|
<input type="text" placeholder="你动我试试" @keydown.tap="showInfo"><br>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
Vue.config.productionTip = false
|
|
|
|
new Vue({
|
|
|
|
el: '#root',
|
|
|
|
data: {
|
|
|
|
name: "haha!"
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
showInfo(e) {
|
|
|
|
console.log(e.key, e.keyCode)
|
|
|
|
console.log(e.target.value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|