]> Repos - mime-chat/commitdiff
initial input item setp
authorriqo <hernandeze2@xavier.edu>
Wed, 21 Oct 2020 14:39:34 +0000 (09:39 -0500)
committerriqo <hernandeze2@xavier.edu>
Wed, 21 Oct 2020 14:39:34 +0000 (09:39 -0500)
src/components/UI/UIDetails/inputItem.vue [new file with mode: 0644]
src/views/home/index.vue

diff --git a/src/components/UI/UIDetails/inputItem.vue b/src/components/UI/UIDetails/inputItem.vue
new file mode 100644 (file)
index 0000000..5eb583c
--- /dev/null
@@ -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>
index 11130b857095e9577ce30d64333b2ddabc8b02b8..d20f30864bbeb268f95a50f991ff8339717c693e 100644 (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>