Last active
October 12, 2022 10:06
-
-
Save barakplasma/c66b2bc8c94b9870f2439b3adc074373 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup> | |
import { ref } from 'vue' | |
const hover = ref(false) | |
const key = ref('') | |
const events = ref([]) | |
document.addEventListener('keydown', (e) => { | |
key.value = e.key; | |
events.value.push({ key: e.key, hover: hover.value.toString() }) | |
}) | |
</script> | |
<template> | |
<h3> | |
Hover (or not) the button below and type | |
</h3> | |
<button @mouseover="hover = true" @mouseleave="hover = false" class="hoverBtn"> | |
Hover: {{hover}} | |
</button> | |
<table> | |
<th>key</th> | |
<th>during hover</th> | |
<tr v-for="ev in events"> | |
<td>{{ev.key}}</td> | |
<td>{{ev.hover}}</td> | |
</tr> | |
</table> | |
</template> | |
<style> | |
.hoverBtn { | |
border: 1px solid black; | |
width: 10rem; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment