What’s the best approach for handling Morse Code conversion while a user is typing? For a simple translator, an input event seems sufficient, but I’m curious how developers handle letter spacing, word separation, invalid characters, and frequent updates efficiently.
A browser-based example is https://morsecodetranslatr.com/
How would you structure the conversion logic for a clean and responsive implementation?
Top comments (3)
I’d separate the conversion logic from the UI and use lookup tables for encoding and decoding. Normalize spaces first, then handle letters and words separately. A standard
inputlistener should be fast enough for normal text, while keeping audio and DOM updates separate will help maintain responsiveness. This also makes it easier to add features later.thanks buddy it help me a lot
i know morse code and i am learning it😄