emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Monitoring KeyRelease


From: Alexander Klimov
Subject: Re: Monitoring KeyRelease
Date: Fri, 6 Jul 2012 21:38:47 +0300

On Thu, 5 Jul 2012, Stefan Monnier wrote:
> > The proper way seems to require handling KeyPress/KeyRelase, but it 
> > seems Emacs currently ignores KeyRelease (xterm.c:6680).
> 
> That could be changed, of course.

Looks like it is more complicated than it seems.

I added logging of KeyPress/KeyRelease: event.xkey.keycode, `[' or ']'
(means press or release), event.xkey.time-last_user_time, and keysym if
ASCII. Turns out I commonly press the next key before releasing the
previous one, for example, `test' looks like

   28 [ 1719 't'
   26 [ 88 'e'
   28 ] 64
   39 [ 24 's'
   26 ] 80
   28 [ 40 't'
   39 ] 40
   28 ] 88

`just a test' looks like

   44 [ 652 'j'
   44 ] 128
   30 [ 128 'u'
   39 [ 80 's'
   30 ] 24
   28 [ 88 't'
   39 ] 72
   65 [ 40 ' '
   28 ] 96
   65 ] 24
   38 [ 48 'a'
   65 [ 136 ' '
   38 ] 48
   65 ] 128
   28 [ 56 't'
   26 [ 88 'e'
   28 ] 24
   39 [ 40 's'
   26 ] 56
   28 [ 48 't'
   39 ] 64
   28 ] 96

while using `f' as a modifier and moving cursor with `j', `l', or `k'
looks like

   41 [ 1136 'f'
   44 [ 328 'j'
   44 ] 96
   44 [ 64 'j'
   44 ] 80
   44 [ 72 'j'
   44 ] 72
   44 [ 72 'j'
   44 ] 120
   46 [ 1257 'l'
   46 ] 55
   46 [ 80 'l'
   46 ] 88
   41 ] 624

That is if I use a key as a modifier it actually takes longer to press 
the next key than when I am typing a word and hold the previous key 
unintentionally.

I guess, we should collect all the event information during KeyPress, 
but do not store the event into the kbd_buffer until we get the 
corresponding KeyRelease. While processing the KeyRelease we should 
add to the corresponding KeyPress event the information about all 
"extended modifiers" which are currently pressed. If we used an 
extended modifier, than we should remember this fact and skip adding 
it to the kbd_buffer while processing its KeyRelease event. A key X 
can be considered as a modifier for key Y, only if X was pressed 
before Y and X is still pressed while Y is released.

overlap:

  ----- time ----->
  t [         ]
  e      [        ]

modifier:

  ----- time ----->
  f [             ]
  j      [     ]

For example,

   28 [ 1719 't'    remember `t'
   26 [ 88 'e'      remember `e'
   28 ] 64          store `t' to kbd_buffer, not `e-t' since `e' was
                    pressed after `t'
   39 [ 24 's'      remember `s'
   26 ] 80          store `e'
   28 [ 40 't'      remember `t'
   39 ] 40          store `s'
   28 ] 88          store `t'

and

   41 [ 1136 'f'    remember `f'
   44 [ 328 'j'     remember `j'
   44 ] 96          store `f-j' (`f' was pressed before `j') and mark
                    `f' as been used as a modifier
   44 [ 64 'j'      remember `j'
   44 ] 80          store `f-j'
              [...]
   41 ] 624         skip `f' since it was used as modifier

Am I missing something and what you think is the best way to 
actually implement this scheme?

-- 
Regards,
ASK



reply via email to

[Prev in Thread] Current Thread [Next in Thread]