Closed 1g0rrr closed 3 months ago
Hi. I just migrated a simple app from cordova to capacitor, and it was working without any plugin, using: @HostListener('document:volumeupbutton') @HostListener('document:volumedownbutton')
I quickly checked the cordova-android plugin and they simply consume the key down events without any action: https://github.com/apache/cordova-android/blob/4742358601e892a8c8816ef8b1827dfdf7b3754e/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L615
For my usecase, I would like to receive the event on key down, because I'm using it in a timer where the precision is important. But I agree that the default behavior should be on key up.
PR is welcome :)
@ryaa That's awesome! Thank! I'll try it in my app and check on different devices
@ryaa Thanks. I started an implementation, but I was yet finding out how the plugin system works. I'm trying also to listen the key down event. I'll give feedback later.
How about to add flag to prevent apearing volume indicator on Android? I'm tryint to make "Push to talk" function in my app by pressing volume button. That's why I need to override default behaviour so volume panel not showed up.
By now I made a "hack" and change KeyEvent.ACTION_UP to KeyEvent.ACTION_DOWN in the line: boolean isKeyUp = event.getAction() == KeyEvent.ACTION_UP; Which is work for my case and prevent volume panel from appearing. But maybe it's better to make cleaner and more universal solution?