Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要一种方法来检查 KeyEvent 以查看它是什么类型。我想排除除设备(智能手机/表格)自己的硬件/电容按钮之外的所有内容。没有鼠标,没有 BT 键盘或游戏手柄等。我只想与它自己的按钮进行交互。这可能吗?
我认为您可以使用 KeyEvent 中的 getDeviceId()。如果它返回 0,则应该是设备本身。
不过,我不知道这有多可靠。