npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

Iโ€™ve always been into building performant and accessible sites, but lately Iโ€™ve been taking it extremely seriously. So much so that Iโ€™ve been building a tool to help me optimize and monitor the sites that I build to make sure that Iโ€™m making an attempt to offer the best experience to those who visit them. If youโ€™re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, ๐Ÿ‘‹, Iโ€™m Ryan Hefnerย  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If youโ€™re interested in other things Iโ€™m working on, follow me on Twitter or check out the open source projects Iโ€™ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soonโ€“ish.

Open Software & Tools

This site wouldnโ€™t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you ๐Ÿ™

ยฉ 2026 โ€“ย Pkg Stats / Ryan Hefner

keyboard-heatmap

v1.0.2

Published

๐ŸŽน A beautiful, lightweight TypeScript package for tracking keyboard usage and generating stunning heatmap visualizations

Downloads

3

Readme

๐ŸŽน keyboard-heatmap

A beautiful, lightweight TypeScript package for tracking keyboard usage and generating stunning heatmap visualizations

npm version npm downloads bundle size TypeScript MIT License

๐Ÿš€ Live Demo โ€ข ๐Ÿ“– Documentation โ€ข ๐Ÿ’ป Examples โ€ข ๐Ÿค Contributing

Keyboard Heatmap Demo


โœจ Features

๐ŸŽฏ Minimal API

  • Simple, intuitive interface
  • Just 3 core functions
  • Works out of the box

๐Ÿ” Privacy First

  • No sensitive data stored
  • Only key frequencies tracked
  • Local processing only

โš›๏ธ React Ready

  • Built-in React hook
  • Auto cleanup on unmount
  • Real-time updates

๐ŸŽจ Beautiful Visuals

  • SVG heatmap generation
  • Customizable colors
  • Responsive design

๐Ÿชถ Lightweight

  • Zero dependencies
  • < 50KB bundle size
  • Tree-shakeable

๐Ÿ“ฑ Cross Platform

  • Works everywhere
  • Desktop & mobile
  • All modern browsers

๐Ÿš€ Quick Start

Installation

npm install keyboard-heatmap

Basic Usage

import { createKeyboardTracker } from 'keyboard-heatmap';

// ๐ŸŽฏ Create and start tracking
const tracker = createKeyboardTracker();
tracker.startTracking();

// ๐Ÿ“Š Get real-time data
const data = tracker.getHeatmapData();
console.log(`Total presses: ${data.totalPresses}`);

// ๐Ÿ›‘ Stop and get final results
const finalData = tracker.stopTracking();

React Hook

import { useKeyboardHeatmap } from 'keyboard-heatmap';

function MyComponent() {
  const { data, isTracking, startTracking, stopTracking } = useKeyboardHeatmap({
    autoStart: true,
    updateInterval: 1000
  });

  return (
    <div>
      <h2>Keyboard Stats</h2>
      <p>Status: {isTracking ? '๐ŸŸข Tracking' : '๐Ÿ”ด Stopped'}</p>
      <p>Total Presses: {data?.totalPresses || 0}</p>
      
      <button onClick={startTracking} disabled={isTracking}>
        Start Tracking
      </button>
      <button onClick={stopTracking} disabled={!isTracking}>
        Stop Tracking
      </button>
    </div>
  );
}

Generate Beautiful Heatmaps

import { generateHeatmapSVG } from 'keyboard-heatmap';

const svgString = generateHeatmapSVG(data, {
  width: 800,
  height: 300,
  colorScale: ['#e3f2fd', '#1976d2'],
  showLabels: true
});

// Use in React
<div dangerouslySetInnerHTML={{ __html: svgString }} />

๐Ÿ’ก Use Cases

| ๐Ÿ“Š Analytics | ๐ŸŽฎ Gaming | ๐Ÿ“š Education | โ™ฟ Accessibility | |:---:|:---:|:---:|:---:| | User behavior tracking | Hotkey optimization | Typing practice | Motor difficulty analysis | | Website analytics | Gaming performance | Speed training | Adaptive keyboards | | UX research | Macro analysis | Learning progress | Usage patterns |


๐Ÿ“– Documentation

Core API

createKeyboardTracker(options?)

Creates a new keyboard tracker instance.

const tracker = createKeyboardTracker({
  ignoreModifierKeys: false,  // Ignore Ctrl, Alt, Shift, etc.
  ignoreSpecialKeys: false,   // Ignore F1-F12, Escape, etc.
  caseSensitive: false        // Treat 'A' and 'a' as different
});

Tracker Methods

| Method | Description | Returns | |--------|-------------|---------| | startTracking() | Begin listening to keyboard events | void | | stopTracking() | Stop tracking and return final data | HeatmapData | | getHeatmapData() | Get current data without stopping | HeatmapData | | isTracking() | Check if currently tracking | boolean | | reset() | Clear all data and stop tracking | void |

React Hook

useKeyboardHeatmap(options?)

const {
  data,           // Current heatmap data
  isTracking,     // Whether tracking is active
  startTracking,  // Function to start tracking
  stopTracking,   // Function to stop tracking
  reset,          // Function to reset all data
  getCurrentData  // Function to get current data
} = useKeyboardHeatmap({
  autoStart: true,        // Start tracking on mount
  updateInterval: 1000,   // Update frequency in milliseconds
  onUpdate: (data) => {}, // Callback for data updates
  // ... other tracker options
});

Visualization

generateHeatmapSVG(data, options?)

const svg = generateHeatmapSVG(heatmapData, {
  width: 800,                    // SVG width
  height: 300,                   // SVG height
  colorScale: ['#fff', '#000'],  // [min color, max color]
  showLabels: true,              // Show key labels and counts
  minOpacity: 0.1,               // Minimum color intensity
  maxOpacity: 1.0                // Maximum color intensity
});

Data Structure

interface HeatmapData {
  frequencies: { [key: string]: number };  // Key press counts
  totalPresses: number;                    // Total number of key presses
  startTime: number;                       // Tracking start timestamp
  endTime?: number;                        // Tracking end timestamp
}

๐Ÿ’ป Examples

Real-time Analytics Dashboard

import { createKeyboardTracker, generateHeatmapSVG } from 'keyboard-heatmap';

class KeyboardAnalytics {
  private tracker = createKeyboardTracker({
    ignoreModifierKeys: true
  });
  
  start() {
    this.tracker.startTracking();
    
    // Update dashboard every 5 seconds
    setInterval(() => {
      const data = this.tracker.getHeatmapData();
      this.updateDashboard(data);
    }, 5000);
  }
  
  updateDashboard(data: HeatmapData) {
    const svg = generateHeatmapSVG(data, {
      colorScale: ['#e8f5e8', '#2e7d32']
    });
    
    document.getElementById('heatmap')!.innerHTML = svg;
    document.getElementById('total')!.textContent = `${data.totalPresses}`;
  }
}

Typing Practice App

import React, { useState } from 'react';
import { useKeyboardHeatmap, generateHeatmapSVG } from 'keyboard-heatmap';

function TypingPractice() {
  const [showResults, setShowResults] = useState(false);
  
  const { data, isTracking, startTracking, stopTracking, reset } = useKeyboardHeatmap({
    ignoreSpecialKeys: true,
    updateInterval: 500,
    onUpdate: (data) => {
      // Calculate typing speed, accuracy, etc.
      const wpm = calculateWPM(data);
      updateStats(wpm);
    }
  });

  const handleFinish = () => {
    stopTracking();
    setShowResults(true);
  };

  return (
    <div className="typing-practice">
      <h1>โŒจ๏ธ Typing Practice</h1>
      
      {!isTracking ? (
        <button onClick={startTracking}>Start Practice</button>
      ) : (
        <button onClick={handleFinish}>Finish</button>
      )}
      
      {showResults && (
        <div className="results">
          <h2>๐Ÿ“Š Your Results</h2>
          <p>Total Key Presses: {data?.totalPresses}</p>
          <div dangerouslySetInnerHTML={{ 
            __html: generateHeatmapSVG(data!, {
              colorScale: ['#fff3cd', '#dc3545']
            })
          }} />
        </div>
      )}
    </div>
  );
}

Gaming Hotkey Analyzer

const gameTracker = createKeyboardTracker({
  caseSensitive: true,
  ignoreModifierKeys: false
});

// Track gaming session
gameTracker.startTracking();

// After gaming session
const gameData = gameTracker.stopTracking();
const topKeys = Object.entries(gameData.frequencies)
  .sort(([,a], [,b]) => b - a)
  .slice(0, 10);

console.log('๐ŸŽฎ Most used gaming keys:', topKeys);

๐ŸŽจ Customization

Color Themes

const themes = {
  ocean: ['#e3f2fd', '#1976d2'],
  forest: ['#e8f5e8', '#2e7d32'],
  sunset: ['#fff3e0', '#f57c00'],
  cherry: ['#fce4ec', '#c2185b'],
  night: ['#263238', '#37474f']
};

const svg = generateHeatmapSVG(data, {
  colorScale: themes.ocean,
  showLabels: true
});

Custom Layouts

// Create your own keyboard layout
const customLayout = {
  width: 600,
  height: 200,
  keys: [
    { key: 'w', x: 50, y: 50, width: 40, height: 40 },
    { key: 'a', x: 10, y: 90, width: 40, height: 40 },
    { key: 's', x: 50, y: 90, width: 40, height: 40 },
    { key: 'd', x: 90, y: 90, width: 40, height: 40 },
    // ... more keys
  ]
};

๐Ÿ› ๏ธ Browser Compatibility

| Browser | Version | Status | |---------|---------|--------| | Chrome | 60+ | โœ… Full Support | | Firefox | 55+ | โœ… Full Support | | Safari | 12+ | โœ… Full Support | | Edge | 79+ | โœ… Full Support | | Mobile | iOS 12+, Android 7+ | โœ… Full Support |


๐Ÿ“ฆ Bundle Size

keyboard-heatmap
โ”œโ”€โ”€ Core (gzipped): ~15KB
โ”œโ”€โ”€ React Hook: ~5KB
โ”œโ”€โ”€ Visualization: ~25KB
โ””โ”€โ”€ Total: ~45KB

Tree-shakeable: Import only what you need!

// Import only core functionality
import { createKeyboardTracker } from 'keyboard-heatmap/core';

// Import only React hook
import { useKeyboardHeatmap } from 'keyboard-heatmap/react';

// Import only visualization
import { generateHeatmapSVG } from 'keyboard-heatmap/visualization';

๐Ÿ”’ Privacy & Security

| ๐Ÿ” What We Track | โŒ What We DON'T Track | |:---:|:---:| | Key press frequencies | Actual text content | | Timing data | Personal information | | Key combinations | Passwords or sensitive data | | Session duration | Keystrokes outside your app |

  • โœ… Local Processing: All data stays in your browser
  • โœ… No Network Calls: Package doesn't make external requests
  • โœ… Clean Cleanup: Proper event listener removal
  • โœ… GDPR Compliant: No personal data collection

๐Ÿšง Roadmap

  • [ ] ๐ŸŒ Multiple Language Support (QWERTZ, AZERTY, etc.)
  • [ ] ๐Ÿ“ฑ Mobile Optimizations (Touch-friendly heatmaps)
  • [ ] ๐ŸŽจ More Visualization Types (3D heatmaps, charts)
  • [ ] ๐Ÿ”Œ Framework Integrations (Vue, Angular, Svelte)
  • [ ] ๐Ÿ“Š Advanced Analytics (Typing speed, patterns)
  • [ ] ๐ŸŽฎ Gaming Features (APM tracking, combo detection)
  • [ ] โ™ฟ Accessibility Tools (Screen reader support)
  • [ ] ๐ŸŒ™ Dark Mode (Built-in dark theme)

๐Ÿค Contributing

We love contributions! See our Contributing Guide for details.

Quick Start for Contributors

# Clone the repo
git clone https://github.com/yourusername/keyboard-heatmap.git
cd keyboard-heatmap

# Install dependencies
npm install

# Run tests
npm test

# Build the package
npm run build

# Start development
npm run dev

Ways to Contribute

  • ๐Ÿ› Bug Reports: Found a bug? Open an issue
  • โœจ Feature Requests: Have an idea? Start a discussion
  • ๐Ÿ“– Documentation: Improve our docs
  • ๐ŸŒ Translations: Help us support more languages
  • ๐Ÿ’ป Code: Submit a pull request

๐Ÿ‘ฅ Community

GitHub Stars GitHub Forks Twitter Follow

โ€ข ๐Ÿ“ง Email


๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


๐Ÿ™ Acknowledgments

  • ๐ŸŽจ Inspired by heat map visualizations
  • โŒจ๏ธ Built for the developer community
  • ๐ŸŒŸ Thanks to all our contributors!

Made with โค๏ธ by Yusif Jabrayilov

Star โญ this repo if you find it useful!

"Buy Me A Coffee"