浏览代码

fix key number (name might be affected by modifiers)

Falko Schindler 3 年之前
父节点
当前提交
7484b5614b
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      nicegui/events.py

+ 1 - 1
nicegui/events.py

@@ -50,7 +50,7 @@ class KeyboardKey(BaseModel):
     @property
     def number(self) -> Optional[int]:
         """Integer value of a number key."""
-        return int(self.name) if self.code.startswith('Digit') else None
+        return int(self.code.removeprefix('Digit')) if self.code.startswith('Digit') else None
 
     @property
     def backspace(self) -> bool: