KeyboardEventArgs属性Code是””,Key是”Undefined”在移动Android上。

huangapple go评论120阅读模式
英文:

KeyboardEventArgs attributes Code is "" and Key is "Undefined" on mobile Android

问题

我尝试使用 Mudblazor MudTextField 的 OnKeyDown。但是当我按下按钮时,KeyboardEventArgs 给出未定义的参数。但我想在软键盘中按下回车键时触发一个函数。是否有其他解决方案来解决这个问题。我已经在 GitHub 上看到了这个问题的报告。

GitHub链接

我非常需要一个答案,请帮助我。

英文:

I tried to use Mudblazor MudTextField's OnKeyDown . But KeyboardEventArgs gives undefined argument when i press a button. But i want to trigger a function when enter button pressed in the soft keyboard. Is there any other solutions for this issue. I have seen this issue reported in github

githublink

I'm desperate for an answer. please help me.

答案1

得分: 1

Android官方关于键盘事件的文档 提到:

> 注意:在处理键盘事件时,使用KeyEvent类和相关API时,应该预期键盘事件仅来自硬件键盘。永远不要依赖于接收软输入法(屏幕键盘)上的任何按键事件。

因此,你不能从软键盘事件中获取按键代码。这是Android本地的限制。

更新:

我进行了再次测试。软键盘的Enter按键事件将触发两次,第二次将获得 e.Key:Entere.Code:。你可以检查一下。

英文:

The native android official document about the KeyBoard event said:

> Note: When handling keyboard events with the KeyEvent class and related APIs, expect that the keyboard events are coming only from a hardware keyboard. Never rely on receiving key events for any key on a soft input method (an on-screen keyboard).

So you can't get the key code from the soft keyboard event. This is android native limit.

Update:

I have tested again. The soft keyboard's enter pressed event will trigger twice and the second time will get the e.Key : Enter and e.Code : . You can check it.

huangapple
  • 本文由 发表于 2023年7月20日 18:07:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76728791.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定