简体   繁体   English

Android物理键盘反馈(Keyclicks)

[英]Android Physical Keyboard Feedback (Keyclicks)

The soft pop up keyboard makes a sound when a key is pressed. 按下键时,软弹出键盘会发出声音。 I would play a sound when a key is pressed on the physical keyboard that we have built into our android hardware. 当我们在Android硬件中内置的物理键盘上按下键时,我会播放声音。 Any advice of how I can do this. 关于如何执行此操作的任何建议。

You can use View.OnKeyListener . 您可以使用View.OnKeyListener It will be invoked only for the Hardware keyboard. 仅硬件键盘将调用它。 Just set it up like this: 像这样设置:

    editText.setOnKeyListener((v, keyCode, event) -> {
        editText.playSoundEffect(SoundEffectConstants.CLICK); // Or play sound in any other way
        return false;
    });

Pay attention to return false . 注意返回false Otherwise your input won't be passed to the view because by returning true you are saying to the framework that your listener handled input already. 否则,您的输入将不会传递到视图,因为通过返回true您是在向框架说您的侦听器已经处理了输入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM