Available on: atari atarixl c128 c64 c64reu coco coco3 cpc d32 d64 mo5 msx1 pc128op plus4 sg1000 to8 vic20

PUT KEY

The PUT KEY command allows you to simulate pressing a key on your computer keyboard. Basically, you enter a string of characters and ugBASIC will use it as if they were typed one after the other. This can be very useful for automating certain actions, such as automatically entering your password or emulating keystrokes.

This can be used to automatically enters a password into a game or application, or to simulate an user interaction with the program itself, such as pressing a button or selecting a menu. It can help to create sequences of commands that are executed automatically, such as a macro.

The maximum length of the string you can enter depends on the keyboard buffer, but normally is up to 10 characters.

Please note that this feature is available with the "asynchronous" keyboard reading mechanism or in some specific, selected targets. To enable this keyboard reading mode you must use the DEFINE KEYBOARD ASYNC.

SYNTAX

 PUT KEY string


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 PUT KEY "yes"


ABBREVIATION: PuKy

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

PUT KEY ↔ PuKy

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS