{
    "content": [
        {
            "type": "text",
            "text": "# Term::ReadKey (perldoc)\n\n## NAME\n\nTerm::ReadKey - A perl module for simple terminal control\n\n## SYNOPSIS\n\nuse Term::ReadKey;\nReadMode 4; # Turn off controls keys\nwhile (not defined ($key = ReadKey(-1))) {\n# No key yet\n}\nprint \"Get key $key\\n\";\nReadMode 0; # Reset tty mode before exiting\n\n## DESCRIPTION\n\nTerm::ReadKey is a compiled perl module dedicated to providing simple control over terminal\ndriver modes (cbreak, raw, cooked, etc.,) support for non-blocking reads, if the architecture\nallows, and some generalized handy functions for working with terminals. One of the main goals\nis to have the functions as portable as possible, so you can just plug in \"use Term::ReadKey\" on\nany architecture and have a good likelihood of it working.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **AUTHOR**\n- **SUPPORT**\n- **LICENSE**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Term::ReadKey",
        "section": "",
        "mode": "perldoc",
        "summary": "Term::ReadKey - A perl module for simple terminal control",
        "synopsis": "use Term::ReadKey;\nReadMode 4; # Turn off controls keys\nwhile (not defined ($key = ReadKey(-1))) {\n# No key yet\n}\nprint \"Get key $key\\n\";\nReadMode 0; # Reset tty mode before exiting",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 8,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 184,
                "subsections": []
            },
            {
                "name": "AUTHOR",
                "lines": 4,
                "subsections": []
            },
            {
                "name": "SUPPORT",
                "lines": 6,
                "subsections": []
            },
            {
                "name": "LICENSE",
                "lines": 23,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Term::ReadKey - A perl module for simple terminal control\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "use Term::ReadKey;\nReadMode 4; # Turn off controls keys\nwhile (not defined ($key = ReadKey(-1))) {\n# No key yet\n}\nprint \"Get key $key\\n\";\nReadMode 0; # Reset tty mode before exiting\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Term::ReadKey is a compiled perl module dedicated to providing simple control over terminal\ndriver modes (cbreak, raw, cooked, etc.,) support for non-blocking reads, if the architecture\nallows, and some generalized handy functions for working with terminals. One of the main goals\nis to have the functions as portable as possible, so you can just plug in \"use Term::ReadKey\" on\nany architecture and have a good likelihood of it working.\n\nVersion 2.30.01: Added handling of arrows, page up/down, home/end, insert/delete keys under\nWin32. These keys emit xterm-compatible sequences. Works with Term::ReadLine::Perl.\n\nReadMode MODE [, Filehandle]\nTakes an integer argument or a string synonym (case insensitive), which can currently be one\nof the following values:\n\nINT   SYNONYM    DESCRIPTION\n\n0    'restore'   Restore original settings.\n\n1    'normal'    Change to what is commonly the default mode,\necho on, buffered, signals enabled, Xon/Xoff\npossibly enabled, and 8-bit mode possibly disabled.\n\n2    'noecho'    Same as 1, just with echo off. Nice for\nreading passwords.\n\n3    'cbreak'    Echo off, unbuffered, signals enabled, Xon/Xoff\npossibly enabled, and 8-bit mode possibly enabled.\n\n4    'raw'       Echo off, unbuffered, signals disabled, Xon/Xoff\ndisabled, and 8-bit mode possibly disabled.\n\n5    'ultra-raw' Echo off, unbuffered, signals disabled, Xon/Xoff\ndisabled, 8-bit mode enabled if parity permits,\nand CR to CR/LF translation turned off.\n\nThese functions are automatically applied to the STDIN handle if no other handle is\nsupplied. Modes 0 and 5 have some special properties worth mentioning: not only will mode 0\nrestore original settings, but it cause the next ReadMode call to save a new set of default\nsettings. Mode 5 is similar to mode 4, except no CR/LF translation is performed, and if\npossible, parity will be disabled (only if not being used by the terminal, however. It is no\ndifferent from mode 4 under Windows.)\n\nIf you just need to read a key at a time, then modes 3 or 4 are probably sufficient. Mode 4\nis a tad more flexible, but needs a bit more work to control. If you use ReadMode 3, then\nyou should install a SIGINT or END handler to reset the terminal (via ReadMode 0) if the\nuser aborts the program via \"^C\". (For any mode, an END handler consisting of \"ReadMode 0\"\nis actually a good idea.)\n\nIf you are executing another program that may be changing the terminal mode, you will either\nwant to say\n\nReadMode 1;             # same as ReadMode 'normal'\nsystem('someprogram');\nReadMode 1;\n\nwhich resets the settings after the program has run, or:\n\n$somemode=1;\nReadMode 0;             # same as ReadMode 'restore'\nsystem('someprogram');\nReadMode 1;\n\nwhich records any changes the program may have made, before resetting the mode.\n\nReadKey MODE [, Filehandle]\nTakes an integer argument, which can currently be one of the following values:\n\n0    Perform a normal read using getc\n-1   Perform a non-blocked read\n>0   Perform a timed read\n\nIf the filehandle is not supplied, it will default to STDIN. If there is nothing waiting in\nthe buffer during a non-blocked read, then undef will be returned. In most situations, you\nwill probably want to use \"ReadKey -1\".\n\n*NOTE* that if the OS does not provide any known mechanism for non-blocking reads, then a\n\"ReadKey -1\" can die with a fatal error. This will hopefully not be common.\n\nIf MODE is greater then zero, then ReadKey will use it as a timeout value in seconds\n(fractional seconds are allowed), and won't return \"undef\" until that time expires.\n\n*NOTE*, again, that some OS's may not support this timeout behaviour.\n\nIf MODE is less then zero, then this is treated as a timeout of zero, and thus will return\nimmediately if no character is waiting. A MODE of zero, however, will act like a normal\ngetc.\n\n*NOTE*, there are currently some limitations with this call under Windows. It may be\npossible that non-blocking reads will fail when reading repeating keys from more then one\nconsole.\n\nReadLine MODE [, Filehandle]\nTakes an integer argument, which can currently be one of the following values:\n\n0    Perform a normal read using scalar(<FileHandle>)\n-1   Perform a non-blocked read\n>0   Perform a timed read\n\nIf there is nothing waiting in the buffer during a non-blocked read, then undef will be\nreturned.\n\n*NOTE*, that if the OS does not provide any known mechanism for non-blocking reads, then a\n\"ReadLine 1\" can die with a fatal error. This will hopefully not be common.\n\n*NOTE* that a non-blocking test is only performed for the first character in the line, not\nthe entire line. This call will probably not do what you assume, especially with \"ReadMode\"\nMODE values higher then 1. For example, pressing Space and then Backspace would appear to\nleave you where you started, but any timeouts would now be suspended.\n\nThis call is currently not available under Windows.\n\nGetTerminalSize [Filehandle]\nReturns either an empty array if this operation is unsupported, or a four element array\ncontaining: the width of the terminal in characters, the height of the terminal in\ncharacter, the width in pixels, and the height in pixels. (The pixel size will only be valid\nin some environments.)\n\n*NOTE*, under Windows, this function must be called with an output filehandle, such as\n\"STDOUT\", or a handle opened to \"CONOUT$\".\n\nSetTerminalSize WIDTH,HEIGHT,XPIX,YPIX [, Filehandle]\nReturn -1 on failure, 0 otherwise.\n\n*NOTE* that this terminal size is only for informative value, and changing the size via this\nmechanism will not change the size of the screen. For example, XTerm uses a call like this\nwhen it resizes the screen. If any of the new measurements vary from the old, the OS will\nprobably send a SIGWINCH signal to anything reading that tty or pty.\n\nThis call does not work under Windows.\n\nGetSpeed [, Filehandle]\nReturns either an empty array if the operation is unsupported, or a two value array\ncontaining the terminal in and out speeds, in decimal. E.g, an in speed of 9600 baud and an\nout speed of 4800 baud would be returned as (9600,4800). Note that currently the in and out\nspeeds will always be identical in some OS's.\n\nNo speeds are reported under Windows.\n\nGetControlChars [, Filehandle]\nReturns an array containing key/value pairs suitable for a hash. The pairs consist of a key,\nthe name of the control character/signal, and the value of that character, as a single\ncharacter.\n\nThis call does nothing under Windows.\n\nEach key will be an entry from the following list:\n\nDISCARD\nDSUSPEND\nEOF\nEOL\nEOL2\nERASE\nERASEWORD\nINTERRUPT\nKILL\nMIN\nQUIT\nQUOTENEXT\nREPRINT\nSTART\nSTATUS\nSTOP\nSUSPEND\nSWITCH\nTIME\n\nThus, the following will always return the current interrupt character, regardless of\nplatform.\n\n%keys = GetControlChars;\n$int = $keys{INTERRUPT};\n\nSetControlChars [, Filehandle]\nTakes an array containing key/value pairs, as a hash will produce. The pairs should consist\nof a key that is the name of a legal control character/signal, and the value should be\neither a single character, or a number in the range 0-255. SetControlChars will die with a\nruntime error if an invalid character name is passed or there is an error changing the\nsettings. The list of valid names is easily available via\n\n%cchars = GetControlChars();\n@cnames = keys %cchars;\n\nThis call does nothing under Windows.\n",
                "subsections": []
            },
            "AUTHOR": {
                "content": "Kenneth Albanowski <kjahds@kjahds.com>\n\nCurrently maintained by Jonathan Stowe <jns@gellyfish.co.uk>\n",
                "subsections": []
            },
            "SUPPORT": {
                "content": "The code is maintained at\n\nhttps://github.com/jonathanstowe/TermReadKey\n\nPlease feel free to fork and suggest patches.\n",
                "subsections": []
            },
            "LICENSE": {
                "content": "Prior to the 2.31 release the license statement was:\n\nCopyright (C) 1994-1999 Kenneth Albanowski.\n2001-2005 Jonathan Stowe and others\n\nUnlimited distribution and/or modification is allowed as long as this\ncopyright notice remains intact.\n\nAnd was only stated in the README file.\n\nBecause I believe the original author's intent was to be more open than the other commonly used\nlicenses I would like to leave that in place. However if you or your lawyers require something\nwith some more words you can optionally choose to license this under the standard Perl license:\n\nThis module is free software; you can redistribute it and/or modify it\nunder the terms of the Artistic License. For details, see the full\ntext of the license in the file \"Artistic\" that should have been provided\nwith the version of perl you are using.\n\nThis program is distributed in the hope that it will be useful, but\nwithout any warranty; without even the implied warranty of merchantability\nor fitness for a particular purpose.\n",
                "subsections": []
            }
        }
    }
}