瀏覽代碼

ignore key events on input fields

Falko Schindler 3 年之前
父節點
當前提交
c18d5ef479
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      nicegui/elements/keyboard.js

+ 5 - 0
nicegui/elements/keyboard.js

@@ -3,6 +3,11 @@ Vue.component("keyboard", {
   mounted() {
     for (const event of this.$props.jp_props.options.activeJSEvents) {
       document.addEventListener(event, (evt) => {
+        // https://stackoverflow.com/a/36469636/3419103
+        const ignored = ["input", "select", "button", "textarea"];
+        const focus = document.activeElement;
+        if (focus && ignored.includes(focus.tagName.toLowerCase())) return;
+
         const e = {
           event_type: "keyboardEvent",
           id: this.$props.jp_props.id,