为箭头绑定绑定键盘方向键
文章来源:https://www.toymoban.com/news/detail-724697.html
<div class="toggle-nav">
<span
v-if="leftToggleSt"
@click="toggleGoods(1)"
@keyup.left="toggleGoods(1)"
class="toggle-left"
>
<a-icon type="left" class="icon" />
</span>
<span
v-if="rightToggleSt"
@click="toggleGoods(2)"
@keyup.right="toggleGoods(2)"
tabindex="0"
class="toggle-right"
>
<a-icon type="right" class="icon" />
</span>
</div>
created() {
const self = this;
document.onkeyup = function(e) {
if (e.key == "ArrowLeft" || e.key == "ArrowUp") {
self.toggleGoods(1);
} else if (e.key == "ArrowRight" || e.key == "ArrowDown") {
self.toggleGoods(2);
}
}
},
methods:{
toggleGoods(){}
}
键盘上各按键对应的英文名文章来源地址https://www.toymoban.com/news/detail-724697.html
到了这里,关于div绑定键盘点击事件的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!