Skip to content

Adding a Calculator Module to the Keyboard #190

@Mokhyy

Description

@Mokhyy

Proposal: Adding a Calculator Module to the Keyboard

One very useful and interesting feature that could be added to the keyboard is a calculator module.
The goal is to let users type mathematical expressions directly inside the keyboard or in text field , see the result immediately, and insert it into the text field without leaving the typing flow.

Core Idea

Instead of implementing a full calculator engine directly inside the keyboard, the keyboard can connect to an external computation engine such as Qalculate.
In this model, the keyboard acts only as the user interface, while the actual calculation is handled by Qalculate. This approach:

  • avoids building the entire calculation engine from scratch
  • provides more advanced and accurate computations
  • makes development and maintenance easier
  • allows support for more complex expressions

Suggested Flow

1) User enters an expression

The user types a mathematical expression inside the keyboard, for example:

2² + 10

2) Expression is sent to the calculation engine

The keyboard sends the expression to Qalculate for processing.

3) Result is returned

Qalculate returns the result, and the keyboard displays it to the user.

4) Result is inserted into the text field

If the user confirms, the result can be inserted directly into the target text field, replacing the original expression.


Result Display Modes

This feature could work in several ways:

  • Show only the result

    • The user sees the answer and decides whether to insert it
  • Show both expression and result

    • The final answer and a preview of the calculation are displayed
    • This is useful for quick review and avoiding mistakes
  • Direct replacement with user confirmation

    • After calculation, the user confirms with a button and the result replaces the expression

Suggested UI

When calculator mode is enabled, a bar could open above the keyboard.
This bar could have three main sections:

  • Input section

    • for entering the mathematical expression
  • Result section

    • for displaying the calculation output
  • Send section

    • a button for sending the result to the target text field

This layout gives the user input, output, and final action in one simple and fast interface.


Trigger-Based Behavior

Similar to Text Expander, a trigger can be defined for the calculator as well.

For example, whenever the user types an expression inside [], it is treated as a mathematical formula.
For instance:

[ 2² + 10 ]=

In this case:

  • the expression 2² + 10 is detected
  • it is sent to Qalculate
  • the result is returned
  • the result is shown in suggestions or in a dedicated area
  • the user can confirm whether it should replace the original expression

This makes the feature fast and aligned with the natural typing flow.


Benefits

  • The user does not need to leave the keyboard
  • Calculations become faster and smoother
  • It is especially useful for quick tasks like addition, percentages, powers, roots, and simple formulas
  • It can become a distinctive and valuable feature of the keyboard

Technical Feasibility

This is technically feasible, since an Android version of Qalculate already exists and can be bound to the keyboard:

https://github.com/jherkenhoff/qalculate-android

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions