Skip to main content
Back to plugins
@capgo/capacitor-volume-buttons
Tutorial
@capgo/capacitor-volume-buttons

Volume Buttons

Capture hardware volume button presses for custom app controls and shortcuts

Guide

Tutorial on Volume Buttons

Using @capgo/capacitor-volume-buttons

Capacitor Volume Buttons Plugin for detecting hardware volume button presses.

Install

bun add @capgo/capacitor-volume-buttons
bunx cap sync

What This Plugin Exposes

  • addListener - Listen for presses on the hardware volume buttons.
  • removeAllListeners - Removes all listeners for this plugin.
  • getPluginVersion - Get the native Capacitor plugin version.

Example Usage

addListener

Listen for presses on the hardware volume buttons.

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

const listener = await VolumeButtons.addListener(
  'volumeButtonPressed',
  (event) => {
    console.log(`Volume ${event.direction} button pressed`);
  }
);

// Remove listener when done
await listener.remove();

removeAllListeners

Removes all listeners for this plugin.

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

await VolumeButtons.removeAllListeners();

getPluginVersion

Get the native Capacitor plugin version.

import { VolumeButtons } from '@capgo/capacitor-volume-buttons';

const { version } = await VolumeButtons.getPluginVersion();
console.log('Plugin version:', version);

Full Reference

Keep going from Using @capgo/capacitor-volume-buttons

If you are using Using @capgo/capacitor-volume-buttons to plan native plugin work, connect it with @capgo/capacitor-volume-buttons for the implementation detail in @capgo/capacitor-volume-buttons, Getting Started for the implementation detail in Getting Started, Capgo Plugin Directory for the product workflow in Capgo Plugin Directory, Capacitor Plugins by Capgo for the implementation detail in Capacitor Plugins by Capgo, and Adding or Updating Plugins for the implementation detail in Adding or Updating Plugins.