ASCII And ANSI Escape Sequences (key-code)

Returns character sequences for any key pressed (ie sent from the terminal)

Description

key-code is a tool used for querying what byte sequence the terminal emulator

Usage

key-code -> <stdout>

<stdin> -> key-code -> <stdout>

Examples

Typical use case

» key-code
Press any key to print its escape constants...

…then press [f9] and key-code returns…

ANSI Constants:   {F9}
Byte Sequence:    %[27 91 50 48 126]
Contains Unicode: false

As a method

» tout str '{ESC}[20~' -> key-code
ANSI Constants:   {F9}
Byte Sequence:    %[27 91 50 48 126]
Contains Unicode: false

Detail

Redirection

If stdout is not a TTY then only the thing written is the ANSI Constant. This is so that it can be used as a variable. eg

key-code -> set $key

event onKeyPress close=$key {
    exit
}

See Also


This document was generated from builtins/events/onKeyPress/keycodes_doc.yaml.

This site's content is rebuilt automatically from murex's source code after each merge to the master branch. Downloadable murex binaries are also built with the website.

Last built on Tue Dec 10 22:56:57 UTC 2024 against commit 60f05a260f05a227caf73dd5b3478e3cb3f4bb24e46745b.

Current version is 6.4.1005 (develop) which has been verified against tests cases.