Skip to main content
AI Math Notes includes keyboard shortcuts to help you work more efficiently without reaching for the mouse buttons.

Available Shortcuts

Undo Last Stroke

Shortcut: Cmd + Z (macOS) or Ctrl + Z (Windows/Linux)Removes the last drawing stroke from the canvas.
self.root.bind("<Command-z>", self.command_undo)
The undo shortcut is bound to the <Command-z> event in Tkinter, which automatically maps to Cmd on macOS and Ctrl on other platforms.

How It Works

When you press the undo shortcut:
  1. The application retrieves the last action from the actions list
  2. Each line in that action is deleted from the canvas
  3. The entire canvas is redrawn from the remaining actions
def command_undo(self, event):
    self.undo()

def undo(self):
    if self.actions:
        last_action = self.actions.pop()
        for line_id, coords in last_action:
            self.canvas.delete(line_id)
        self.redraw_all()
Each stroke (from mouse down to mouse up) counts as one action. You can undo multiple strokes by pressing the shortcut repeatedly.

Keyboard Bindings Reference

Here’s a quick reference table of all keyboard shortcuts:
ActionmacOSWindows/LinuxFunction
UndoCmd + ZCtrl + ZRemove last stroke
CalculateReturnEnterSolve the equation

Event Binding in Code

The shortcuts are implemented using Tkinter’s event binding system:
class DrawingApp:
    def __init__(self, root):
        # ... other initialization code ...
        
        # Keyboard shortcuts
        self.root.bind("<Command-z>", self.command_undo)
        self.root.bind("<Return>", self.command_calculate)
Tkinter’s <Command-z> binding automatically handles platform differences:
  • On macOS: Maps to Command (⌘) key
  • On Windows/Linux: Maps to Control (Ctrl) key

Mouse Bindings

In addition to keyboard shortcuts, the application uses mouse event bindings for drawing:
self.canvas.bind("<Button-1>", self.start_draw)        # Left click
self.canvas.bind("<B1-Motion>", self.paint)            # Drag with left button
self.canvas.bind("<ButtonRelease-1>", self.reset)      # Release left button
Event: <Button-1> (Left mouse button click)Initiates a new drawing stroke and creates a new action.
def start_draw(self, event):
    self.current_action = []
    self.last_x, self.last_y = event.x, event.y

No Clear Shortcut

There is currently no keyboard shortcut for the Clear function. You must click the Clear button to reset the entire canvas.
If you want to remove just the last few strokes, use Cmd/Ctrl + Z repeatedly instead of clearing everything.

Build docs developers (and LLMs) love