initial input item setp

This commit is contained in:
riqo 2020-10-21 09:39:34 -05:00
commit b27b21d5d6
2 changed files with 50 additions and 6 deletions

View file

@ -0,0 +1,42 @@
<template>
{{ input }}
</template>
<script>
import { defineComponent, ref, onUnmounted } from "vue";
export default defineComponent({
name: "InputItem",
setup() {
const input = ref("");
function handleInput(e) {
const inputCode = e.keyCode;
const cmd = String.fromCharCode(inputCode).toLowerCase();
switch(inputCode) {
case 13:
console.log('enter was pressed');
break;
case 8:
console.log('delete was pressed');
input.value = input.value.slice(0, -1);
break;
default:
input.value += cmd;
}
}
window.addEventListener("keydown", handleInput);
onUnmounted(() => {
window.removeEventListener("keydown", handleInput);
})
return {
input
}
}
})
</script>

View file

@ -1,17 +1,19 @@
<template>
<UIindex />
<Microphone />
<!-- <UIindex />
<Microphone /> -->
<InputItem />
</template>
<script lang="ts">
import { defineComponent, onMounted } from 'vue';
import UIindex from "@/components/UI/index.vue";
import Microphone from "@/components/microphone/index.vue";
import { defineComponent } from 'vue';
// import UIindex from "@/components/UI/index.vue";
// import Microphone from "@/components/microphone/index.vue";
import InputItem from "@/components/UI/UIDetails/inputItem.vue";
export default defineComponent({
name: "HomeIndex",
components: { UIindex, Microphone },
components: { InputItem },
});
</script>