当前位置:网站首页>9. Keyboard events
9. Keyboard events
2022-07-20 08:40:00 【Where the wind falls】
1. Key aliases commonly used in keyboards
1.Vue Key aliases commonly used in
enter :enter
Delete :delete
sign out :esc
Space :space
Change the number :tab
On :up
Next :down
Left :left
Right :right
2.vue Key with no alias provided , You can use the original... Key key Value to bind , But be careful to turn to keyab-case( short ), Such as :@keyup.page-down
3. System modifier ( Special usage ):ctrl、alt、shift、meta
(1) coordination keyup Use : Colleagues who press the modifier key , Press another key , Then release the other keys , The event was
Trigger .
(2) coordination keydown Use : Normal trigger event
4. You can also use keyCode To specify specific keys ( Not recommended 、vue3 Has deleted )
5.Vue.config.keycodes. Custom key name = Key code , You can customize the key alias
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title> Keyboard events </title>
<!-- introduce Vue -->
<script type="text/javascript" src="../js/vue.js"></script>
</head>
<body>
<!--
1.Vue Key aliases commonly used in :
enter => enter
Delete => delete ( Capture “ Delete ” and “ Backspace ” key )
sign out => esc
Space => space
Line break => tab ( special , Must cooperate keydown To use the )
On => up
Next => down
Left => left
Right => right
2.Vue Key with no alias provided , You can use the original... Key key Value to bind , But be careful to turn to kebab-case( The dash names )
3. System modifier keys ( Special usage ):ctrl、alt、shift、meta
(1). coordination keyup Use : While pressing the modifier key , Press another key , Then release the other keys , The event was triggered .
(2). coordination keydown Use : Normal trigger event .
4. You can also use keyCode To specify specific keys ( Not recommended )
5.Vue.config.keyCodes. Custom key name = Key code , You can customize the key alias
-->
<!-- Prepare a container -->
<div id="root">
<h2> Welcome to {
{name}} Study </h2>
<input type="text" placeholder=" Press enter to prompt for " @keydown.huiche="showInfo">
</div>
</body>
<script type="text/javascript">
Vue.config.productionTip = false // prevent vue Generate production prompts at startup .
Vue.config.keyCodes.huiche = 13 // Defines an alias key
new Vue({
el:'#root',
data:{
name:' Silicon Valley '
},
methods: {
showInfo(e){
// console.log(e.key,e.keyCode)
console.log(e.target.value)
}
},
})
</script>
</html>
边栏推荐
猜你喜欢
A long detailed explanation of C language dynamic memory management
标准IO与文件IO
枚举(enum)奇妙的使用、联合体(共用体union)对空间节省的巧妙
C language program environment and preprocessing
三子棋(N子棋)C语言编程实现,超详细讲解
Easier to use C language entry-level cheese (1) data types, variables and constants, strings + escape characters + comments (super detailed)
Recursive backtracking - maze walking
【学习笔记】Unreal(虚幻)4引擎入门(三)
74-学生管理系统-添加-删除-展示
Process to thread and incoming thread communication
随机推荐
【js】var 和 let 在 for 循环中的不同反应
Character functions and string functions
区间覆盖问题
4000 words, let you understand recursion and its example practice (C language, with pictures)
习题集
找免费录屏软件的过程-没想到win10自带这个功能
Part 59: main c:62:9: note: use option -std=c99 or -std=gnu99 to compile your code
C language implementation of address book
Mise en œuvre du carnet d'adresses en langage C
11.监视属性——watch
Easier to use C language entry-level cheese (3) common keywords +define+ pointer + structure (super detailed)
Pytorch mmdetection2.0 installation training test (coco training set)
Heap sorting and heap related operations
【学习笔记】Unreal(虚幻)4引擎入门(四)
位运算——异或
C语言实现通讯录
What if the game needs to be reinstalled after the steam folder is moved
Pytorch implements retinanet (III) definition and training of loss
已故苹果联合创始人乔布斯被追授美国总统自由勋章
15.内置指令