This document describes the format for defining key bindings and mouse bindings.

The resource name for a binding consists of:
  *  Puzzle set name
  *  One of <tt>editClick</tt>, <tt>editKey</tt>, <tt>gameClick</tt>, or <tt>gameKey</tt>
  *  Zero or more components for modifier keys: <tt>shift</tt>, <tt>ctrl</tt>, <tt>alt</tt>, <tt>meta</tt>, and/or <tt>numLock</tt> (you may not combine <tt>numLock</tt> with any other modifiers except <tt>shift</tt>)
  *  Key name (or mouse button)

You are not allowed to use <tt>?</tt> modifiers for the key name or mouse button or modifier keys, although you can use <tt>*</tt> anywhere, and <tt>?</tt> can be used in place of the first and/or second components.

If you define a binding without num lock but do not define the corresponding binding with num lock, then that key combination (or mouse button) will do the same thing when num lock is on than when num lock is not on.

The definition of a binding can be:
  *  Built-in miscellaneous
  *  Rewind
  *  Advance
  *  Reset
  *  Input a move
  *  External command
  *  SQL statement

<h2>Built-in miscellaneous</h2>
Consists of <tt>^</tt> followed by one more character.

(TODO: Mention what commands are available.)


Consists of <tt>-</tt> to rewind, <tt>+</tt> to advance, or <tt>=</tt> to reset, followed by a nonnegative integer in decimal notation.

This will rewind or advance the move list, or reset the move list to the beginning. In the case of rewind or advance it tells how many moves to rewind or advance by. In case of reset, it specifies how many moves to advance after it is reset (normally you should specify zero).

These commands are not valid in the level editor.

<h2>Input a move</h2>
Consists of <tt>'</tt> followed by a [Hero Mesh key name].

This will begin a new game turn, and then record the move just made (unless the move is ignored with the IgnoreKey instruction, in which case the state of the game remains unchanged).

These commands are not valid in the level editor.

<h2>External command</h2>
Consists of <tt>!</tt> followed by a shell command.

Executes the given command and waits for it to return.

<h2>SQL statement</h2>
Consists of a single SQL statement (which must not begin with a comment). Only one SQL statement is allowed; you are not allowed more than one. The statement is prepared when Free Hero Mesh starts. The statement should be or use the sqlInit resource if you need to execute other statements.

The SQL statement will be executed when the key/mouse is pushed. If there are any result rows, they are interpreted as follows: The first column is a string consisting of exactly two characters, telling what operation should be performed; the rest of the columns are the arguments. Any extra arguments are ignored, although since later versions of Free Hero Mesh might use them for something, it is recommended to use null values in the extra columns for compatibility with future.

See also [SQL tables] and [SQL functions]. Extensions may define additional tables/functions that can be used.