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

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

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

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

Parameters

data: Uint8Array | string