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

tech-rex-keyboard

v1.0.4

Published

Reusable Phaser UI components, keyboard input system and layout manager using Rex

Readme

tech-rex-keyboard

A reusable Phaser UI components library featuring a keyboard input system and layout manager using Rex.

Description

tech-rex-keyboard provides an interactive HTML input overlay system for Phaser games. It enables native HTML input fields to be positioned precisely over Phaser game objects, with support for:

  • Responsive positioning based on game canvas scaling
  • Text fitting to specified box dimensions
  • Mobile keyboard handling (portrait/landscape)
  • Live value sanitization (numeric decimal input)
  • ScaleManager integration for safe resizing

Installation

npm install tech-rex-keyboard

Usage

Basic Usage

import { Controller_input } from 'tech-rex-keyboard';

// In your Phaser scene:
preload() {
    // Load your assets
}

create() {
    // Create an input zone (e.g., a rectangle or sprite)
    const inputZone = this.add.rectangle(x, y, width, height, 0x000000, 0);
    
    // Create a text object to display the input value
    const inputText = this.add.text(x, y, '0.00', { 
        fontSize: '24px',
        fontFamily: 'Arial'
    });
    
    // Initialize the input controller
    const inputController = Controller_input(inputZone, inputText, this);
}

API

Controller_input(input, InputText, gScene)

Creates an interactive input overlay for Phaser games.

Parameters:

| Parameter | Type | Description | |------------|------|-------------| | input | Phaser.GameObjects.GameObject | The interactive game object (zone, sprite, etc.) that triggers the input | | InputText | Phaser.GameObjects.Text | The text object to display the input value | | gScene | Phaser.Scene | The Phaser scene instance |

Returns:

An object with the following methods:

| Method | Description | |--------|-------------| | hideKeyboard() | Programmatically closes the keyboard and finalizes the input |

Features

Text Fitting to Box

The fitTextToBox function ensures input text fits within a specified maximum width:

function fitTextToBox(text, textObject, maxWidth) {
    // Binary search algorithm to find the longest text that fits
    // Returns the fitted text string
}
  • Supports suffix-based fitting -Preserves original text state
  • Returns the longest fitting text

Responsive Positioning

The input overlay automatically:

  • Calculates position relative to game canvas
  • Accounts for Phaser scale manager transformations
  • Updates position on every postupdate tick
  • Handles both portrait and landscape orientations

Input Sanitization

  • Accepts only numeric input (0-9)
  • Allows single decimal point
  • Formats output as decimal with 2 decimal places
  • Handles negative values (defaults to 0.00)

Mobile Keyboard Handling

  • Locks container height in landscape mode to prevent layout shifts
  • Sets active input Y position for ScaleManager
  • Freezes canvas resizing during editing
  • Scrolls viewport to top-left to prevent layout shifts

Example: Numeric Input Field

import { Controller_input } from 'tech-rex-keyboard';

class GameScene extends Phaser.Scene {
    create() {
        // Create input background
        const inputBg = this.add.rectangle(400, 300, 200, 50, 0x333333);
        inputBg.setInteractive({ useHandCursor: true });
        
        // Create input text
        const inputText = this.add.text(400, 300, '0.00', {
            fontSize: '32px',
            fontFamily: 'Arial',
            color: '#ffffff'
        }).setOrigin(0.5);
        
        // Initialize controller
        const input = Controller_input(inputBg, inputText, this);
        
        // Store reference if needed
        this.inputController = input;
    }
    
    // To programmatically hide keyboard:
    hideInput() {
        if (this.inputController) {
            this.inputController.hideKeyboard();
        }
    }
}

License

MIT License

Copyright (c) 2024 TECHTEAM

Keywords

  • Phaser
  • HTML5 Game
  • UI Components
  • Keyboard Input
  • Rex