Skip to content

Commit

Permalink
filter keyboard events by type to ignore autocompletion
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Jan 31, 2025
1 parent 0e9f650 commit 8f1ebc1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nicegui/elements/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ export default {
mounted() {
for (const event of this.events) {
document.addEventListener(event, (evt) => {
// https://github.com/zauberzeug/nicegui/issues/4290
if (!(evt instanceof KeyboardEvent)) return;

// https://stackoverflow.com/a/36469636/3419103
const focus = document.activeElement;
if (focus && this.ignore.includes(focus.tagName.toLowerCase())) return;

if (evt.repeat && !this.repeating) return;

this.$emit("key", {
action: event,
altKey: evt.altKey,
Expand Down

0 comments on commit 8f1ebc1

Please sign in to comment.