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 🙏

© 2025 – Pkg Stats / Ryan Hefner

d-pad

v1.0.7

Published

easy keyboard navigation without having to change your html

Downloads

94

Readme

free navigation

  • Adds keyboard navigation to any page without changing the HTML
  • Framework friendly: Doesn't add or remove any html: elements, classes or attributes - meaning it won't make any conflicts with your existing framework's client state
  • Opt-in behaviour: Simply importing the library will not override any page behaviour, and it can be enabled at the per-element level
  • Auto flow (opt-in): enables your focus to automatically be shifted to the next element once you hit the character limit on the current input

Getting Started

Import the library in your client side.

<script src="https://unpkg.com/[email protected]"></script>

Enable the library at the level of your DOM you desire. i.e.:

<body class="dp-enable">

Add some styling to ensure your users can understand where their cursor is:

a:focus-visible, select:focus-visible, *[tabindex]:focus-visible {
	outline: 3px solid blue;
}

.dp-group:focus-visible {
	outline: 1px dashed blue !important;
	box-shadow: inset 0 0 5px 0 blue;
}

/* Alternatively you can import directly from unpkg */
@import url("https://unpkg.com/[email protected]/styles.css");

Navigation

Using d-pad attempts to follow the same behaviour of current browser standards to make it intuitive to existing users. Using the arrow keys will attempt to change the focus to the nearest focusable element in that direction within the current dp-group.

You can tell d-pad to ignore certain elements during this navigation via giving them the CSS class dp-ignore.

Groups (dp-group)

We allow grouping navigable elements together using the CSS class dp-group. This can allow the user to skip over large sections without navigating through each one individually. When a dp-group is focused, you can enter the group using Space.

group navigation

Auto Flow (dp-flow-auto)

When flow-auto is enabled, when an <input> has reached it's maximum input length, when using Backspace on a <input>/<textarea> making it blank, d-pad will attempt to auto-navigate to the next/previous input.

auto flow

Features

All features are enabled and disabled using CSS classes, meaning you won't need to add any extra attributes to elements that might cause your linter or React to freak out.

| Class | Behaviour | | :- | :- | | dp-enable | This element and all children will have d-pad movement enabled on them | | dp-disable | Disable d-pad for the children of this element | | dp-flow-auto | This element and it's children will have auto flow enabled | | dp-flow-strict | This element and it's children will not have auto flow | | dp-ignore | This element is ignored during navigation | | dp-group | This element itself should be treated as something navigable with nodes inside it |

Tips

Form Locking

To prevent accidental navigation out of a form you can add the dp-group and dp-ignore CSS classes to your <form>, meaning you will not be able to navigate into our out of the form by the keyboard, but once inside can navigate freely.

Event Overrides

If you have a custom element such as a searchable drop down in create, make sure to bind your keyboard navigation on keydown and call ev.stopImmediatePropagation() to prevent d-pad from also attempting to consume that event.

Alternatively add the class dp-disable to the root of your element to disable all navigation from that element.

Non-Input Element Focusing

By default when you attempt focus an element such as a <div>, the browser does nothing. Non-input elements must have a tabindex property before they can become focusable, so if you want focus navigation to a <div> we recommend adding the attribute tabindex="0".

Customization

You can specify which directions d-pad should attempt to travel when an input is completed, or you attempt to backspace out of it.

dpad.autoFlow = {
  next: [ dpad.direction.right, dpad.direction.down ],
  back: [ dpad.direction.left,  dpad.direction.up ]
}

Examples

See https://d-pad.ajanibilby.com/example