You are browsing as a guest. Sign up (or log in) to start making projects!

3h 45m 50s logged

Dev log #2 Getting the hotkeys to actually work

The shortcuts finally fire and copy text. Getting there took most of the session though.

I first set up the Alt+S and Alt+E shortcuts in TypeScript since that’s the language I’m comfortable in. Bad idea. They broke every time I reloaded the page, threw errors I didn’t understand, and sometimes fired twice. After a lot of digging I figured out the problem. The shortcut is an OS-level thing, but I’d tied it to the React frontend, which reloads constantly while I’m developing, so it kept losing track of itself.

The fix was to move the shortcut registration over to the Rust side and let React just listen for when a shortcut gets pressed. That killed the whole pile of bugs at once. This was day one of me actually writing Rust so it took a while to get there.

Most of today was honestly just me with the Tauri docs and the Rust book open side by side. I was looking up basically everything. How Rust handles ownership and errors, how Tauri wants the backend and frontend to talk to each other, what half the functions even did. It was grueling. There were a few moments where I just stared at the screen wondering what I’d gotten myself into. But the docs are solid and stuff slowly started clicking, and by the end it felt good to actually understand what I was writing.

A couple smaller things I ran into. The copy only worked once I triggered on key release instead of key press, otherwise Alt was still held down and jammed the copy. And Firefox steals the Alt key for its own menu, so I’ll switch to Alt+Shift later or add custom shortcuts.

So the core loop works now. Highlight text anywhere, press the shortcut, and the app grabs it. Seeing it actually work after all that was a great feeling. I also added a little system tray icon, with menus, so it runs in the background.

Next up: make the floating window pop up near my cursor and show the result. Wire a shortcut to an LLM call.

0
55

Comments 1

@firancly

learning basics of rust here