capacitor-keyboard

cap-go/capgo-skills · updated Apr 8, 2026

$npx skills add https://github.com/cap-go/capgo-skills --skill capacitor-keyboard
0 commentsdiscussion
summary

Manage keyboard behavior in iOS and Android apps.

skill.md

Keyboard Handling in Capacitor

Manage keyboard behavior in iOS and Android apps.

When to Use This Skill

  • User has keyboard issues
  • User needs keyboard events
  • User wants to hide keyboard
  • User has scroll issues with keyboard
  • User wants keyboard accessory bar

Quick Start

npm install @capacitor/keyboard
npx cap sync

Basic Usage

import { Keyboard } from '@capacitor/keyboard';

// Show keyboard
await Keyboard.show();

// Hide keyboard
await Keyboard.hide();

// Listen for keyboard events
Keyboard.addListener('keyboardWillShow', (info) => {
  console.log('Keyboard height:', info.keyboardHeight);
});

Keyboard.addListener('keyboardWillHide', () => {
  console.log('Keyboard hiding');
});

Configuration

// capacitor.config.ts
plugins: {
  Keyboard: {
    resize: 'body',        // 'body' | 'ionic' | 'native' | 'none'
    style: 'dark',         // 'dark' | 'light' | 'default'
    resizeOnFullScreen: true,
  },
},

Resize Modes

Mode Description
body Resize body element
ionic Use Ionic's keyboard handling
native Native WebView resize
none No automatic resize

Handle Keyboard Height

import { Keyboard } from '@capacitor/keyboard';
import { Capacitor } from '@capacitor/core';

if (Capacitor.isNativePlatform()) {
  Keyboard.addListener('keyboardWillShow', (info) => {
    document.body.style.setProperty(
      '--keyboard-height',
      `${info.keyboardHeight}px`
    );
  });

  Keyboard.addListener('keyboardWillHide', () => {
    document.body.style.setProperty('--keyboard-height', '0px');
  });
}
.chat-input {
  position: fixed;
  bottom: calc(var(--keyboard-height, 0px) + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
}

Scroll to Input

Keyboard.addListener('keyboardWillShow', async (info) => {
  const activeElement = document.activeElement as HTMLElement;

  if (activeElement) {
    // Wait for keyboard animation
    await new Promise((r) => setTimeout(r, 100));

    activeElement.scrollIntoView({
      behavior: 'smooth',
      block: 'center',
    });
  }
});

iOS Accessory Bar

// Show/hide the toolbar above keyboard
await Keyboard.setAccessoryBarVisible({ isVisible: true });

Form Best Practices

// Prevent zoom on iOS (use font-size >= 16px)
input {
  font-size: 16px;
}

// Handle form submission
form.addEventListener('submit', async (e) => {
  e.preventDefault();
  await Keyboard.hide();
  // Process form
});

// Move to next field
input.addEventListener('keypress', (e) => {
  if (e.key === 'Enter') {
    const nextInput = getNextInput();
    if (nextInput) {
      nextInput.focus();
    } else {
      Keyboard.hide();
    }
  }
});

Troubleshooting

Issue Solution
Content hidden Use resize mode
Slow animation Use keyboardWillShow
iOS zoom Use 16px font-size
Android overlap Set windowSoftInputMode

Resources

Discussion

Product Hunt–style comments (not star reviews)
  • No comments yet — start the thread.
general reviews

Ratings

4.642 reviews
  • Shikha Mishra· Dec 28, 2024

    Keeps context tight: capacitor-keyboard is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Yusuf Farah· Dec 28, 2024

    capacitor-keyboard reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Ganesh Mohane· Dec 20, 2024

    capacitor-keyboard reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Anaya Singh· Dec 12, 2024

    Registry listing for capacitor-keyboard matched our evaluation — installs cleanly and behaves as described in the markdown.

  • Anika Dixit· Dec 8, 2024

    Keeps context tight: capacitor-keyboard is the kind of skill you can hand to a new teammate without a long onboarding doc.

  • Sakura White· Dec 8, 2024

    I recommend capacitor-keyboard for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Ama Martinez· Nov 27, 2024

    capacitor-keyboard reduced setup friction for our internal harness; good balance of opinion and flexibility.

  • Noah Shah· Nov 19, 2024

    I recommend capacitor-keyboard for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Sakshi Patil· Nov 11, 2024

    I recommend capacitor-keyboard for anyone iterating fast on agent tooling; clear intent and a small, reviewable surface area.

  • Sofia Liu· Nov 3, 2024

    Useful defaults in capacitor-keyboard — fewer surprises than typical one-off scripts, and it plays nicely with `npx skills` flows.

showing 1-10 of 42

1 / 5