Bluetooth key bindings and custom actions
This document explains how to configure Bluetooth key bindings and add new actions to the available actions list.
Overview
Bluetooth key binding support allows users to map buttons on Bluetooth input devices (remotes, keyboards, etc.) to KOReader actions. When a button is pressed, KOReader triggers the corresponding event.
Available actions
The list of available actions that users can bind to buttons is defined in
src/lib/bluetooth/available_actions.lua.
Each action entry has:
id: Unique identifier for the action (used internally)title: Display name shown to users in the UI (translated with_())event: KOReader event name to trigger when the button is pressedargs: Optional arguments to pass to the event (e.g.,-1for previous page,1for next page)description: User-friendly description of what the action does (translated)
Example action entry:
{
id = "next_page",
title = _("Next Page"),
event = "GotoViewRel",
args = 1,
description = _("Go to next page"),
},
Adding a new action
Prerequisites
- Know the KOReader event name you want to trigger (check
apps/reader/readerui.luaor other reader modules for available events) - Understand what arguments the event accepts (if any)
- Provide localized strings using
_()for the title and description
Steps
- Open
src/lib/bluetooth/available_actions.lua - Add a new entry to the
AVAILABLE_ACTIONStable following the structure above - Important: Insert the entry in alphabetical order by the
titlefield to maintain UI consistency - Use descriptive names and user-friendly descriptions
- Test the action by configuring a key binding and pressing the button on your device
Example: Adding a bookmark navigation action
{
id = "next_bookmark",
title = _("Next Bookmark"),
event = "GotoNextBookmark",
description = _("Jump to next bookmark"),
},
How key bindings work internally
- User presses a button on the Bluetooth device
- The
InputDeviceHandlerdetects the button press via the device's input event interface - The handler looks up the configured action id for that button
- The corresponding KOReader event is triggered with any arguments
- KOReader processes the event normally
Testing custom actions
- Add your new action to
available_actions.lua - Pair a Bluetooth input device and connect to it
- Configure a key binding to use your new action
- Press the button and verify the expected behavior occurs
Common KOReader events
Here are some common events you might want to bind to:
GotoViewRel: Navigate pages (arg: 1 for next, -1 for previous)GotoNextChapter/GotoPrevChapter: Chapter navigationDecreaseFontSize/IncreaseFontSize: Font size controlShowMenu: Open reader menuToggleFrontlight: Toggle screen lightToggleBookmark: Add/remove bookmark
For a complete list, refer to the KOReader source code in apps/reader/modules/ and
apps/reader/readerui.lua.
Important notes
- Keep the
AVAILABLE_ACTIONStable sorted alphabetically by title for consistent UI ordering - Always provide translations for titles and descriptions
- Test that the event works correctly in the reader before adding it
- Document complex arguments clearly in the action description