Don't ask to ask, just ask | |
PerlMonks |
Re: Morse input from keyboardby kcott (Archbishop) |
on Feb 11, 2020 at 07:21 UTC ( [id://11112760]=note: print w/replies, xml ) | Need Help?? |
G'day pierrot, "The idea is that you press a single key and depending on how long you press it, that stroke is interpreted as a dot or a dash." Here's a very basic implementation that does that using Tk. The Tk::Button widget invokes its callback (the -command code) when the button is released, so that implements "depending on how long you press it"; although, quickly pressing and releasing the button, then varying the time between presses, produces the same effect. The website you linked has a lot of other features, such as translating input into actual characters and accomodating multiple users. You didn't ask for that and, if you want one or more of those features, I'd suggest giving it a bash yourself — it'd be a good learning exercise if nothing else. I did retain the [key] label that's used there. Also note that I just used the time function; take a look at Time::HiRes core module which provides higher resolution time functions.
— Ken
In Section
Seekers of Perl Wisdom
|
|