Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/cliffy/packages/keycode/mod.ts>KeyCode

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
class KeyCode
import { KeyCode } from "https://deno.land/x/cliffy@v0.10.0/packages/keycode/mod.ts";

Static Methods

protected
parseEscapeSequence(data: Uint8Array | string): KeyEvent

Some patterns seen in terminal key escape codes, derived from combos seen at http://www.midnight-commander.org/browser/lib/tty/key.c

ESC letter ESC [ letter ESC [ modifier letter ESC [ 1 ; modifier letter ESC [ num char ESC [ num ; modifier char ESC O letter ESC O modifier letter ESC O 1 ; modifier letter ESC N letter ESC [ [ num ; modifier char ESC [ [ 1 ; modifier letter ESC ESC [ num char ESC ESC O letter

  • char is usually ~ but $ and ^ also happen with rxvt
  • modifier is 1 + (shift * 1) + (left_alt * 2) + (ctrl * 4) + (right_alt * 8)
  • two leading ESCs apparently mean the same as one leading ESC
parse(data: Uint8Array | string): KeyEvent | undefined