英文:
KeyboardEventArgs attributes Code is "" and Key is "Undefined" on mobile Android
问题
我尝试使用 Mudblazor MudTextField 的 OnKeyDown。但是当我按下按钮时,KeyboardEventArgs 给出未定义的参数。但我想在软键盘中按下回车键时触发一个函数。是否有其他解决方案来解决这个问题。我已经在 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
I'm desperate for an answer. please help me.
答案1
得分: 1
> 注意:在处理键盘事件时,使用KeyEvent类和相关API时,应该预期键盘事件仅来自硬件键盘。永远不要依赖于接收软输入法(屏幕键盘)上的任何按键事件。
因此,你不能从软键盘事件中获取按键代码。这是Android本地的限制。
更新:
我进行了再次测试。软键盘的Enter按键事件将触发两次,第二次将获得 e.Key:Enter
和 e.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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论