capacitor-custom-button
v0.0.6
Published
Hardware volume buttons listener for Capacitor
Downloads
168
Readme
[!IMPORTANT]
This repository has been merged into @capacitor-community/volume-buttons, where is it going to be actively maintained
capacitor-volume-buttons
Hardware volume buttons listener for Capacitor
Install
npm install capacitor-custom-button
npx cap sync
Quick example
useEffect(() => {
const onCustomButtonPressed = ({ isLongPress }: CustomButtonPressed) => {
console.log(key);
};
const listener = CustomButton.addListener('customButtonPressed', onCustomButtonPressed);
return () => {
listener.remove();
};
}, []);
API
addListener('customButtonPressed', ...)
addListener(event: 'customButtonPressed', listenerFunc: CustomButtonPressedListener) => Promise<PluginListenerHandle> & PluginListenerHandle
Listen for presses on the hardware volume buttons
| Param | Type |
| ------------------ | ----------------------------------------------------------------------------------- |
| event
| 'customButtonPressed' |
| listenerFunc
| CustomButtonPressedListener |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
Since: 1.0.0
removeAllListeners()
removeAllListeners() => Promise<void>
Removes all listeners for this plugin
Since: 1.0.0
Interfaces
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove
| () => Promise<void> |
Type Aliases
CustomButtonPressedListener
({ isLongPress }: CustomButtonPressed): void
CustomButtonPressed
{ isLongPress: boolean }