Skip to main content

Fundamentals

As noted in the first page, something fundamental to know is that, with some exceptions, what you write with Simkey is interpreted as a key expression by default.

Now we will discuss the basics of how to manipulate pressing and releasing keys in simkey.

First of all, a key expression does not have any spaces or lines in it. Once you add spaces it is no longer one whole key expression. In other words, these expressions are also the basic unit by which manipulating keys is done.

Different actions in a key expression

There are essentially three types of ways you can handle a key with an expression:

  1. Press the key without holding it ― simply type the key
  2. Holding the key ― with the syntax |...|
  3. Holding, but with |... ― with no closing |.

The way #2,3 work is like a switch. If the key is not already being held, it gets held, otherwise it gets released.

The differences between them show up when it comes to releasing already held keys, where there is a small variation in how the timing is handled. Refer to this part of the next page for more information after reading about how delays work.

Pressing without holding

This way of manipulating keys is very simple, you simply write the key out. When writing it without any spaces or new line (so in a single key expression), the keys are pressed together than released together. Here's an example:

abc # Presses a,b,c together then releases them #

If you want to type out keys that are more the one letter in name, such as SHIFT, write [SHIFT] and it will be interpreted in that way instead of each letter in the name individually being pressed.

SHIFT # Presses and releases s,h,i,f,t alongside CAPS_LOCK or SHIFT to make it capital #
[SHIFT] # Presses and releases SHIFT #
note

To escape a character, use \. Works the same way it does in other languages, and you can use it in any part of a key expression.

warning

Notice that the idea of a key expression is that it is a basic unit by which you can click keys together. As such, an expression containing duplicates like aa does not make sense, and it will raise an error.

Holding the key

We will ignore the differences between the two ways of holding for now.

Same as above, you can do several keys simultaneously. Here's an example with some comments to clarify:

|abc # Presses a,b,c and doesn't release them #

# Note we can split up when we release these keys, they don't have to be released together! #

|a # Since a is already held, releases it #
|bcd # Since b is already held, releases it, same applies for c, but then d gets held #

|[SHIFT] # Presses SHIFT, doesn't release it #
|[SHIFT] # Since SHIFT is already being held, releases it #

Combining pressing and holding

This notation for holding and pressing without holding can be combined in one key expression, just remember, the holding part must come at the end. Here's an example:

abc|[SHIFT] # Presses a,b,c,SHIFT releases a,b,c #
|[SHIFT] # Now SHIFT is released #
warning

In these expressions, all the keys get pressed at roughly the same time, but of course not exactly at the same time, so the held keys are pressed very slightly before. Keep this in mind when using combined expressions.

How to handle timing in key expressions

The timing is done in the form of delays, which control how long keys are pressed before they are released (when they are not being held), as well as how long to wait before moving onto the next key expression.

There are two types of delays, those being hold, and wait. hold controls how long to wait before releasing the keys, while wait controls how long to wait before running the next key expression. There are generally three ways to set these two delays.

Using @delay

One way is setting a default delay, using the @delay builtin function:

@delay [50,50] # First argument is `hold`, second is `wait` #

abc # Presses a,b,c then sleeps for 50ms, releases a,b,c then sleeps for 50ms #

# ...every key expression will have the 50ms `wait` and 50ms `hold` delay by default #

Using @hold/@wait

Alternatively, you can set the hold and wait separately by using their builtin functions:

@hold [50] # Sets the `hold` #
@wait [50] # Sets the `wait` #

abc # Presses a,b,c then sleeps for 50ms, releases a,b,c then sleeps for 50ms #

# ...every key expression will have the 50ms `wait` and 50ms `hold` delay by default #

Inline delays

The last way is by setting them inline. The key expressions allow you to use tags on each side to set delays; the one on the left being hold, and the other being wait. A note is that you do not need to include both, and this does not affect the default delay.

Here's an example:

@delay [50,50] # First argument is `hold`, second is `wait` #

<100>abc<100> # Presses a,b,c then sleeps for 100ms, releases a,b,c then sleeps for 100ms #

<100>abc # Presses a,b,c then sleeps for 100ms, releases a,b,c then sleeps for 50ms (from default) #

# ...every key expression will have the 50ms `wait` and 50ms `hold` delay by default #
note

By default, the delay set is 100 ms for hold, and 100 ms for wait.

Getting the program to sleep

If you just want to have the program sleep for some time, you can use a tag without any keys to the right and it'll simply wait.

For example:

@delay [50,50] # First argument is `hold`, second is `wait` #

abc # Presses a,b,c then sleeps for 50ms, releases a,b,c then sleeps for 50ms #

<5000> # Wait for 5 seconds #

# ...everything later will come 5100 ms after the first `key expression` #

List of Multiple Letter Keys

As shown above, when you want to press something like shift, you must put square brackets around it and use a specific name (in this case, [SHIFT]). We will list them in the tables below.

This is based on the RunKeyC.c app as of writing this table. Keep in mind that the compiler actually does not check if a key is valid, and all you would have to do is swap out the file running the KeyC to alter or expand this list.

Key NameSimkey CodeKey NameSimkey Code
EnterENTERCaps LockCAPS
ShiftSHIFTTabTAB
CtrlCTRLListLIST
AltALTEndEND
SpaceSPACEPrint ScreenPRNTSCR
EscESCScroll LockSCRL_LOCK
Left ArrowLEFTPausePAUSE
Right ArrowRIGHTPage UpPG_UP
Up ArrowUPPage DownPG_DOWN
Down ArrowDOWNHomeHOME
Left Mouse Button (left click)MB_LEFTIns (Insert)INS
Scroll Wheel ButtonMB_MIDDLEDel (Delete)DEL
Right Mouse ButtonMB_RIGHTWindows Key (or Command)WIN

Some things to note

There are some caveats to the delays system that will be covered on the next page, such as that with the two different syntaxes for holding keys. There are also some errors you might encounter when exploring these expressions yourself that are not explicitly mentioned here. View the next page for some more detail.