@capgo/capacitor-volume-buttons
React to the hardware volume buttons in your Capacitor app, to take a photo, turn a page or trigger any action.
Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.
➡️ Get started for free
14-day unlimited free trial. No credit card required
🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use
@capgo/capacitor-volume-buttonsin your Capacitor app:npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-volume-buttons to my Capacitor app and wire it up." Agent setup guides · Hosted MCP
Key features
- Button events: the
volumeButtonPressedlistener reportsupordown. - iOS: watches the audio session output volume.
- Android: listens for volume key events.
- Clean up:
removeAllListeners()removes your listeners. Native monitoring stops when the plugin instance is destroyed. - Platforms: iOS and Android. Not available on web.
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
You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins
Then use the following prompt:
Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-volume-buttons` plugin in my project.
If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:
npm install @capgo/capacitor-volume-buttons
npx cap sync
API
addListener('volumeButtonPressed', ...)removeAllListeners()getPluginVersion()- Interfaces
- Type Aliases
Capacitor Volume Buttons Plugin for detecting hardware volume button presses.
addListener('volumeButtonPressed', ...)
addListener(eventName: 'volumeButtonPressed', listenerFunc: VolumeButtonListener) => Promise<PluginListenerHandle> & 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()
removeAllListeners() => Promise<void>
Removes all listeners for this plugin.
Since: 1.0.0
getPluginVersion()
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'