Output: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 termkey.pl 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.
In reply to Re: Can I capture string typING in STDIN without press enter?
by daxim
in thread Can I capture string typING in STDIN without press enter?
by exilepanda
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |