Skip to content

AnalogSense/JavaScript-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

24 Commits

Repository files navigation

AnalogSense.js

JavaScript API for analog keyboard input.

Supported Keyboards/Devices

  • Everything by Wooting
  • Everything by NuPhy
  • Everything by DrunkDeer
  • Razer Huntsman V2 AnalogR
  • Razer Huntsman Mini AnalogR
  • Razer Huntsman V3 ProR
  • Razer Huntsman V3 Pro MiniR
  • Razer Huntsman V3 Pro TenkeylessR
  • Keychron Q1 HEP, F
  • Keychron Q3 HEP, F
  • Keychron Q5 HEP, F
  • Keychron K2 HEP, F
  • Lemokey P1 HEP, F
  • Madlions MAD60HEP
  • Madlions MAD68HEP
  • Madlions MAD68RP

R Razer Synapse needs to be installed and running for analogue inputs to be received from this keyboard.

P The official firmware only supports polling, which can lead to lag and missed inputs.

FCustom firmware with full analog report functionality is available.

Usage

You can download and vendor the AnalogSense.js yourself, but you can also just load it straight from this repo:

<scriptsrc="https://analogsense.org/JavaScript-SDK/AnalogSense.js"></script>

Once loaded, the following global functions become available:

  • analogsense.getDevices(): Promise<Device[]>
  • analogsense.requestDevice(): Promise<Device | undefined>
  • analogsense.scancodeToString(scancode: number): string

A device instance has the following members:

  • startListening(handler: function<void({scancode: int, value: float}[])>)
  • stopListening()
  • getProductName(): string
  • forget()
  • dev: HIDDevice

Scancodes

The scancodes provided by this library are primarily HID scancodes; most keys are mapped as seen on usage page 0x07 (A = 0x04, B = 0x05, ...).

Control keys (usage page 0x0C) are mapped in the 0x3__ range, modulo 0x100:

  • 0x3B5 = Next Track
  • 0x3B6 = Previous Track
  • 0x3B7 = Stop Media
  • 0x3CD = Play/Pause
  • 0x394 = Open File Explorer
  • 0x323 = Open Browser Home Page

OEM-specific keys are mapped in the 0x4__ range:

  • 0x401 = Brightness Up
  • 0x402 = Brightness Down
  • 0x403 = Profile 1
  • 0x404 = Profile 2
  • 0x405 = Profile 3
  • 0x408 = Profile Switch
  • 0x409 = Function Key (Fn)

About

JavaScript API for analog keyboard input.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •