import { feedkeys } from "https://deno.land/x/denops_std@v5.0.2/function/mod.ts";
Characters in {string} are queued for processing as if they come from a mapping or were typed by the user.
By default the string is added to the end of the typeahead buffer, thus if a mapping is still being executed the characters come after them. Use the 'i' flag to insert before other characters, they will be executed next, before any characters from a mapping.
The function does not wait for processing of keys contained in {string}.
To include special keys into {string}, use double-quotes
and "..." notation expr-quote
. For example,
feedkeys("\<CR>"
) simulates pressing of the <Enter>
key. But
feedkeys('<CR>') pushes 5 characters.
A special code that might be useful is <Ignore>
, it exits the
wait for a character without doing anything.
{mode} is a String, which can contain these character flags:
'm' Remap keys. This is default. If {mode} is absent,
keys are remapped.
'n' Do not remap keys.
't' Handle keys as if typed; otherwise they are handled as
if coming from a mapping. This matters for undo,
opening folds, etc.
'L' Lowlevel input. Only works for Unix or when using the
GUI. Keys are used as if they were coming from the
terminal. Other flags are not used.
When a CTRL-C interrupts and 't' is included it sets
the internal "got_int" flag.
'i' Insert the string instead of appending (see above).
'x' Execute commands until typeahead is empty. This is
similar to using ":normal!". You can call feedkeys()
several times without 'x' and then one time with 'x'
(possibly with an empty {string}) to execute all the
typeahead. Note that when Vim ends in Insert mode it
will behave as if <Esc>
is typed, to avoid getting
stuck, waiting for a character to be typed before the
script continues.
Note that if you manage to call feedkeys() while
executing commands, thus calling it recursively, then
all typeahead will be consumed by the last call.
'c' Remove any script context when executing, so that
legacy script syntax applies, "s:var" does not work,
etc. Note that if the string being fed sets a script
context this still applies.
'!' When used with 'x' will not end Insert mode. Can be
used in a test when a timer is set to exit Insert mode
a little later. Useful for testing CursorHoldI.
Return value is always 0.
Can also be used as a method
:
GetInput()->feedkeys()