https://github.com/cap-go/capacitor-volume-buttons
Capacitor plugin to listen to volume button presses
https://github.com/cap-go/capacitor-volume-buttons
capacitor capacitor-plugin
Last synced: 4 months ago
JSON representation
Capacitor plugin to listen to volume button presses
- Host: GitHub
- URL: https://github.com/cap-go/capacitor-volume-buttons
- Owner: Cap-go
- License: mpl-2.0
- Created: 2025-10-09T16:29:54.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2026-02-06T05:19:58.000Z (4 months ago)
- Last Synced: 2026-02-06T13:41:05.029Z (4 months ago)
- Topics: capacitor, capacitor-plugin
- Language: JavaScript
- Homepage: https://capgo.app
- Size: 1020 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
README
# @capgo/capacitor-volume-buttons

Listen to volume button presses in Capacitor apps
## Documentation
The most complete doc is available here: https://capgo.app/docs/plugins/volume-buttons/
## Compatibility
| Plugin version | Capacitor compatibility | Maintained |
| -------------- | ----------------------- | ---------- |
| v8.\*.\* | v8.\*.\* | ✅ |
| v7.\*.\* | v7.\*.\* | On demand |
| v6.\*.\* | v6.\*.\* | ❌ |
| v5.\*.\* | v5.\*.\* | ❌ |
> **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.
## Install
```bash
npm install @capgo/capacitor-volume-buttons
npx cap sync
```
## API
* [`addListener('volumeButtonPressed', ...)`](#addlistenervolumebuttonpressed-)
* [`removeAllListeners()`](#removealllisteners)
* [`getPluginVersion()`](#getpluginversion)
* [Interfaces](#interfaces)
* [Type Aliases](#type-aliases)
Capacitor Volume Buttons Plugin for detecting hardware volume button presses.
### addListener('volumeButtonPressed', ...)
```typescript
addListener(eventName: 'volumeButtonPressed', listenerFunc: VolumeButtonListener) => Promise & PluginListenerHandle
```
Listen for presses on the hardware volume buttons.
| Param | Type | Description |
| ------------------ | --------------------------------------------------------------------- | ------------------------------------------------------ |
| **`eventName`** | 'volumeButtonPressed' | - The event name (must be 'volumeButtonPressed') |
| **`listenerFunc`** | VolumeButtonListener | - The function to call when a volume button is pressed |
**Returns:** Promise<PluginListenerHandle> & PluginListenerHandle
**Since:** 1.0.0
--------------------
### removeAllListeners()
```typescript
removeAllListeners() => Promise
```
Removes all listeners for this plugin.
**Since:** 1.0.0
--------------------
### getPluginVersion()
```typescript
getPluginVersion() => Promise<{ version: string; }>
```
Get the native Capacitor plugin version.
**Returns:** Promise<{ version: string; }>
**Since:** 1.0.0
--------------------
### Interfaces
#### PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| **`remove`** | () => Promise<void> |
#### VolumeButtonPressed
Event data for volume button press.
| Prop | Type | Description |
| --------------- | ----------------------------------------------------------------------- | ----------------------------- |
| **`direction`** | VolumeButtonDirection | Direction of the button press |
### Type Aliases
#### VolumeButtonListener
Listener function for volume button events.
(event: VolumeButtonPressed): void
#### VolumeButtonDirection
Direction of volume button press.
'up' | 'down'