wiki:0.2/UsersGuide/cr3

Translations:

Short instruction

Redefining the keybindings in  CoolReader

The keybindings are defined in two files: keydefs.ini and keymaps.ini.

keydefs.ini contains the symbolic names for keys and commands. These names are used in keymaps.ini. There should be no need to modify this file, the latest standard version will suffice.

keymaps.ini lists the keybindings for different windows. Comments begin with #. The file is split into sections. Each of them starts with the name of the section in square brackets. So, the section main refers to the main window of the program:

[main] 
'1' = DCMD_LINK_BACK 
'1', LONG = DCMD_LINK_FORWARD

Section names:

  • main - the main CoolReader window with the text.
  • menu - menu
  • vkeyboard - virtual keyboard
  • txkeyboard - Т9/Т5 keyboard
  • browse - Various information window: dictionary article, book description.
  • dialog - other dialogs

Keybinding definitions:

KEY [, LONG] = COMMAND [, parameter]

KEY is a decimal or hexadecimal (with 0x prefix) key code, or a symbol in apostrophes ('1'), or a symbolic name defined in keydefs.ini.

Keys available in V3:

  • XK_Return - Ok
  • XK_Escape - Esc
  • XK_Up / XK_Down - Arrow keys on the left side
  • '0'..'9' - digit keys
  • '+'/'-' - volume keys

Modifier LONG (or 1) after the key code denotes a long key press (the short one, or 0, is the default).

For some commands, the command code may be followed by an optional parameter after a comma (for example, the number of pages to skip).

Example:

'0' = DCMD_PAGEDOWN 
'0', LONG = DCMD_PAGEDOWN, 10 

Available commands:

In the book browsing window:

DCMD_BEGIN - Go to the first page

DCMD_PAGEUP - Go one page back (optional parameter: number of pages)

DCMD_PAGEDOWN - Go one page forward (optional parameter: number of pages)

DCMD_LINK_FORWARD - Move forward in link history (if possible)

DCMD_LINK_BACK - Move back after a jump by link or page number

DCMD_LINK_NEXT - Pick next link on the current page

DCMD_LINK_PREV - Pick previous link on the current page

DCMD_LINK_GO - Follow the selected link

DCMD_END - Go to the last page

DCMD_GO_PAGE - Go to the page by number (mandatory parameter: page number)

DCMD_ZOOM_IN - Increase font size (parameter: number of steps)

DCMD_ZOOM_OUT - Decrease font size (parameter: number of steps)

DCMD_TOGGLE_TEXT_FORMAT - Toggle auto-formatting of text files

DCMD_BOOKMARK_SAVE_N - Save bookmark (parameter: bookmark number)

DCMD_BOOKMARK_GO_N - Go to bookmark (parameter: bookmark number)

DCMD_MOVE_BY_CHAPTER - Go to next/previous chapter (parameter: 1 - next chapter; -1 - previous chapter)

MCMD_QUIT - Quit program. Do not redefine this command, it must be bound to Esc!!!

MCMD_MAIN_MENU - Main menu

MCMD_GO_PAGE - Open the contents and page selection dialog

MCMD_SETTINGS - Open the settings dialog

MCMD_SETTINGS_FONTSIZE - Open the font size selection dialog

MCMD_SETTINGS_ORIENTATION - Open the page orientation dialog

MCMD_GO_LINK - Link selection mode

MCMD_LONG_FORWARD - Move forward in jumps history

MCMD_LONG_BACK - Move back in jumps history

MCMD_DICT - Dictionary search dialog (T5/T9)

MCMD_BOOKMARK_LIST - Bookmarks list

MCMD_RECENT_BOOK_LIST - List of last read books

MCMD_OPEN_RECENT_BOOK - Open a book from the list of last read books (parameter - book number)

MCMD_ABOUT - About the program, book description

MCMD_CITE - Select the quotation to save

MCMD_SEARCH - Search dialog

MCMD_DICT_VKEYBOARD - Dictionary search dialog, virtual keyboard

MCMD_KBD_NEXTLAYOUT - Next keyboard layout in virtual keyboard or in T9

MCMD_KBD_PREVLAYOUT - Previous keyboard layout in virtual keyboard or in T9

MCMD_HELP - Help (for the next version of CoolReader)

MCMD_HELP_KEYS - Show the list of keybindings

In menus:

MCMD_CANCEL - Close menu, cancel changes

MCMD_OK - Close menu, apply changes

MCMD_SCROLL_FORWARD - page forward through a multipage menu

MCMD_SCROLL_BACK - page back through a multipage menu

MCMD_SELECT_0 - Select 0

MCMD_SELECT_1 - Select 1

...

MCMD_SELECT_9 - Select 9

MCMD_SELECT_0_LONG - Select 0, long key press

...

MCMD_SELECT_9_LONG - Select 9, long key press

MCMD_SCROLL_FORWARD_LONG - Move some pages forward

MCMD_SCROLL_BACK_LONG - Move some pages back

New versions of the files may be downloaded from  keydefs.ini,  keymaps.ini

To modify the standard settings copy the modified files to the crengine directory on the SD card or the internal memory.

You don't have to list all the keys in keymaps.ini, just list the keybindings you want to change.