Skip to content

Instantly share code, notes, and snippets.

@barakplasma
Last active October 12, 2022 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barakplasma/c66b2bc8c94b9870f2439b3adc074373 to your computer and use it in GitHub Desktop.
Save barakplasma/c66b2bc8c94b9870f2439b3adc074373 to your computer and use it in GitHub Desktop.
<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