@@ -293,7 +293,8 @@ added: v0.1.98 |
293 | 293 |
|
294 | 294 | The `rl.write()` method will write either `data` or a key sequence identified |
295 | 295 | by `key` to the `output`. The `key` argument is supported only if `output` is |
296 | | -a [TTY][] text terminal. |
| 296 | +a [TTY][] text terminal. See [TTY keybindings][] for a list of key |
| 297 | +combinations. |
297 | 298 |
|
298 | 299 | If `key` is specified, `data` is ignored. |
299 | 300 |
|
@@ -722,6 +723,131 @@ const { createInterface } = require('readline'); |
722 | 723 | })(); |
723 | 724 | ``` |
724 | 725 |
|
| 726 | +## TTY keybindings |
| 727 | + |
| 728 | +<table> |
| 729 | + <tr> |
| 730 | + <th>Keybindings</th> |
| 731 | + <th>Description</th> |
| 732 | + <th>Notes</th> |
| 733 | + </tr> |
| 734 | + <tr> |
| 735 | + <td><code>ctrl</code> + <code>shift</code> + <code>backspace</code></td> |
| 736 | + <td>Delete line left</td> |
| 737 | + <td>Doesn't work on Linux, Mac and Windows</td> |
| 738 | + </tr> |
| 739 | + <tr> |
| 740 | + <td><code>ctrl</code> + <code>shift</code> + <code>delete</code></td> |
| 741 | + <td>Delete line right</td> |
| 742 | + <td>Doesn't work on Linux and Mac</td> |
| 743 | + </tr> |
| 744 | + <tr> |
| 745 | + <td><code>ctrl</code> + <code>c</code></td> |
| 746 | + <td>Emit <code>SIGINT</code> or close the readline instance</td> |
| 747 | + <td></td> |
| 748 | + </tr> |
| 749 | + <tr> |
| 750 | + <td><code>ctrl</code> + <code>h</code></td> |
| 751 | + <td>Delete left</td> |
| 752 | + <td></td> |
| 753 | + </tr> |
| 754 | + <tr> |
| 755 | + <td><code>ctrl</code> + <code>d</code></td> |
| 756 | + <td>Delete right or close the readline instance in case the current line is empty / EOF</td> |
| 757 | + <td>Doesn't work on Windows</td> |
| 758 | + </tr> |
| 759 | + <tr> |
| 760 | + <td><code>ctrl</code> + <code>u</code></td> |
| 761 | + <td>Delete from the current position to the line start</td> |
| 762 | + <td></td> |
| 763 | + </tr> |
| 764 | + <tr> |
| 765 | + <td><code>ctrl</code> + <code>k</code></td> |
| 766 | + <td>Delete from the current position to the end of line</td> |
| 767 | + <td></td> |
| 768 | + </tr> |
| 769 | + <tr> |
| 770 | + <td><code>ctrl</code> + <code>a</code></td> |
| 771 | + <td>Go to start of line</td> |
| 772 | + <td></td> |
| 773 | + </tr> |
| 774 | + <tr> |
| 775 | + <td><code>ctrl</code> + <code>e</code></td> |
| 776 | + <td>Go to to end of line</td> |
| 777 | + <td></td> |
| 778 | + </tr> |
| 779 | + <tr> |
| 780 | + <td><code>ctrl</code> + <code>b</code></td> |
| 781 | + <td>Back one character</td> |
| 782 | + <td></td> |
| 783 | + </tr> |
| 784 | + <tr> |
| 785 | + <td><code>ctrl</code> + <code>f</code></td> |
| 786 | + <td>Forward one character</td> |
| 787 | + <td></td> |
| 788 | + </tr> |
| 789 | + <tr> |
| 790 | + <td><code>ctrl</code> + <code>l</code></td> |
| 791 | + <td>Clear screen</td> |
| 792 | + <td></td> |
| 793 | + </tr> |
| 794 | + <tr> |
| 795 | + <td><code>ctrl</code> + <code>n</code></td> |
| 796 | + <td>Next history item</td> |
| 797 | + <td></td> |
| 798 | + </tr> |
| 799 | + <tr> |
| 800 | + <td><code>ctrl</code> + <code>p</code></td> |
| 801 | + <td>Previous history item</td> |
| 802 | + <td></td> |
| 803 | + </tr> |
| 804 | + <tr> |
| 805 | + <td><code>ctrl</code> + <code>z</code></td> |
| 806 | + <td>Moves running process into background. Type |
| 807 | + <code>fg</code> and press <code>enter</code> |
| 808 | + to return.</td> |
| 809 | + <td>Doesn't work on Windows</td> |
| 810 | + </tr> |
| 811 | + <tr> |
| 812 | + <td><code>ctrl</code> + <code>w</code> or <code>ctrl</code> |
| 813 | + + <code>backspace</code></td> |
| 814 | + <td>Delete backwards to a word boundary</td> |
| 815 | + <td><code>ctrl</code> + <code>backspace</code> Doesn't |
| 816 | + work as expected on Windows</td> |
| 817 | + </tr> |
| 818 | + <tr> |
| 819 | + <td><code>ctrl</code> + <code>delete</code></td> |
| 820 | + <td>Delete forward to a word boundary</td> |
| 821 | + <td>Doesn't work on Mac</td> |
| 822 | + </tr> |
| 823 | + <tr> |
| 824 | + <td><code>ctrl</code> + <code>left</code> or |
| 825 | + <code>meta</code> + <code>b</code></td> |
| 826 | + <td>Word left</td> |
| 827 | + <td><code>ctrl</code> + <code>left</code> Doesn't work |
| 828 | + on Mac</td> |
| 829 | + </tr> |
| 830 | + <tr> |
| 831 | + <td><code>ctrl</code> + <code>right</code> or |
| 832 | + <code>meta</code> + <code>f</code></td> |
| 833 | + <td>Word right</td> |
| 834 | + <td><code>ctrl</code> + <code>right</code> Doesn't work |
| 835 | + on Mac</td> |
| 836 | + </tr> |
| 837 | + <tr> |
| 838 | + <td><code>meta</code> + <code>d</code> or <code>meta</code> |
| 839 | + + <code>delete</code></td> |
| 840 | + <td>Delete word right</td> |
| 841 | + <td><code>meta</code> + <code>delete</code> Doesn't work |
| 842 | + on windows</td> |
| 843 | + </tr> |
| 844 | + <tr> |
| 845 | + <td><code>meta</code> + <code>backspace</code></td> |
| 846 | + <td>Delete word left</td> |
| 847 | + <td>Doesn't work on Mac</td> |
| 848 | + </tr> |
| 849 | +</table> |
| 850 | + |
725 | 851 | [`'SIGCONT'`]: readline.html#readline_event_sigcont |
726 | 852 | [`'SIGTSTP'`]: readline.html#readline_event_sigtstp |
727 | 853 | [`'line'`]: #readline_event_line |
@@ -731,5 +857,6 @@ const { createInterface } = require('readline'); |
731 | 857 | [`rl.close()`]: #readline_rl_close |
732 | 858 | [Readable]: stream.html#stream_readable_streams |
733 | 859 | [TTY]: tty.html |
| 860 | +[TTY keybindings]: #readline_tty_keybindings |
734 | 861 | [Writable]: stream.html#stream_writable_streams |
735 | 862 | [reading files]: #readline_example_read_file_stream_line_by_line |