TypeKeys Method (AnyWin)




  • Classic Agent: Sends a set of keystrokes or mouse button presses to the window.
  • Open Agent: Sends a set of keystrokes to the window.


window.TypeKeys (sEvents [, nDelay, ensureFocus])
Variable Description
sEvents The keystrokes to type or mouse buttons to press. Mouse buttons are supported on the Classic Agent only. To specify mouse buttons, use <Button1>, <Button2>, or <Button3> in the string. STRING.
nDelay Optional: The delay between keystrokes (in seconds and fractions of seconds). NUMBER.

Optional: Whether the agent brings the application to the foreground and then sets the keyboard focus to the control on which the method is executed. This is executed before the first key is typed, which means it is not rechecked for each keystroke when you specify multiple keys to be typed.

This variable is supported only in scripts that use the Open Agent.

By default, this variable is set to TRUE. BOOLEAN.


  • On Windows, TypeKeys first gives the window input focus before typing into it.
  • If you specify nDelay, that value overrides the value set with the OPT_KEYBOARD_DELAY option, which you set with SetOption.
  • Some keystrokes are not supported on mobile devices.
  • See Key Names for a list of key names.
  • A key can be followed by a counter, which defines how often the keys should be typed. The counter can be combined with the delay.
  • During the delay time, the screen is locked and interaction with the mouse and keyboard is no longer possible.
  • When recording with the DOM extension, TypeKeys ("<Tab>") will not be captured. Since the script refers to object to type in directly, it is not necessary to record this manual Tab. You can manually enter a TypeKeys ("<Tab>") into your script if you want to; it will just not be recorded.
  • When specifying groups of keys, such as Ctrl+Shift, the Classic Agent only supports minus signs (-) as a delimiter between key names while the Open Agent supports plus and minus signs.
  • If the TypeKeys method does not work as expected, you can try the SetText method.
  • The Cmd modifier is supported with the Open Agent for Mozilla Firefox on macOS.


//shift-right will be executed 6 times
TextEditor.Document.TypeKeys ("<Shift-Right 6>")
//Shift-Right will be executed 6 times with a delay of 3 seconds before each execution
TextEditor.Document.TypeKeys ("<Shift-Right 6>", 3)
//Selects all elements in the active field in Mozilla Firefox on macOS
BrowserWindow.TypeKeys ("Cmd+A")