Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Can I capture string typING in STDIN without press enter?

by daxim (Chaplain)
on May 29, 2012 at 16:36 UTC ( #973067=note: print w/replies, xml ) Need Help??

in reply to Can I capture string typING in STDIN without press enter?

Slightly modified synopsis of Term::TermKey::Async:
use strictures; use Term::TermKey::Async qw(FORMAT_VIM KEYMOD_CTRL); use IO::Async::Loop; use Time::HiRes qw(time); binmode STDOUT, ':encoding(UTF-8)'; my $loop = IO::Async::Loop->new; my $tka = Term::TermKey::Async->new( term => \*STDIN, on_key => sub { my ($self, $key) = @_; printf "Got key: %.8f %s\n", time, $self->format_key($key, FOR +MAT_VIM); $loop->loop_stop if $key->type_is_unicode and $key->utf8 eq "C +" and $key->modifiers & KEYMOD_CTRL; }, ); $loop->add($tka); $loop->loop_forever;
$ perl
Got key: 1338309112.93089604 我
Got key: 1338309112.93100500 喜
Got key: 1338309112.93102598 欢
Got key: 1338309115.18962908 吃
Got key: 1338309116.35776711 冰
Got key: 1338309116.35783195 淇
Got key: 1338309116.35785198 淋
Got key: 1338309116.78892303 。
You can see clearly from the timestamps how I grouped the words/phrases in the input method editor. Only once a phrase is complete in the IME, it is passed off to the terminal.

I haven't tested this on Windows.

Replies are listed 'Best First'.
Re^2: Can I capture string typING in STDIN without press enter?
by exilepanda (Pilgrim) on May 30, 2012 at 14:58 UTC
    Thanks but no luck... Term::TermKey is not available for Win32 =( Besides.. in win cmd prompt, there's no unicode, chars are formed in ANSI sequence. But thanks again.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://973067]
[Corion]: marto: Heh - I think that's a nice contractual trap, "you will not use other gods/engines besides ours" ;)
[Corion]: But if the base intention was to have CIG as "co-developers" who (have to) contribute changes back to the mainline, it makes sense to have them use no other engine
[marto]: yes, I hear that development house has been on its last legs for a couple of years now
[Corion]: Is anybody aware of what makes Android Oreo better than Android Nougat? I'm not sure if the architectural changes (etc) are there already that make upgrading an Oreo-kernel phone to a newer Android userland (Lineage OS) version feasible
[Corion]: Yeah, CryTek got blindsided (or whatever) by Unity and Unreal Engine being zero cost, and the CryTek documentation being bad/nonexistent I think
[Corion]: "zero monetary cost", because of course, it's gratis only if your time has no value :)
[marto]: I used to keep up to date with my android ROMs, updating to the nightly every other day
[marto]: in my experience the jump in major releases has been painless, and performed better

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-12-14 10:39 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (389 votes). Check out past polls.