unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#22163: Feature request: Add support for key release event
@ 2015-12-13  8:58 Simon Friis Vindum
  2015-12-14 22:17 ` John Wiegley
  2015-12-15 20:15 ` Simon Friis Vindum
  0 siblings, 2 replies; 4+ messages in thread
From: Simon Friis Vindum @ 2015-12-13  8:58 UTC (permalink / raw)
  To: 22163

[-- Attachment #1: Type: text/plain, Size: 2263 bytes --]

Dear Emacs developers

I apologize if this feature has been requested before. I was not able to
find any such requests.

The feature request:
It should be possible to bind functions to the _release_ of a key.
Additionally it would also be nice if it was possible to get the current
state of a key. I.e. is it pressed or not.

As far is I understand implementing this in the terminal is impossible—so
this feature would be for graphical environments only.

Motivation:
Here are a few ideas that I've wanted to implement as Emacs extensions.
They all turned out to be impossible due to the lack of this feature. To
implement them it would be necessary to be notified both when a key is
pressed and when a keys is released.

1/ The possibility of bindings commands to the long press of a key. For
instance I would bind a long press of `s` to `isearch-forward` and a long
press of `n` to `avy-goto-line-below`. The extension would calculate this
time difference between key press and release. And based on that decide
between short- and long-press behaviour.

2/ An extension that would make it possible to use a regular key as a
modifier key. For instance holding `j` with the right hand could activate
"wasd" directional keys for the left hand. Or holding `a` could activate
vim-like directional keys with "hjkl". The possibilities are many.

3/ Get press and hold behaviour independent of the OSs key repeat
behaviour. If I bind a function (e.g. one that scrolls the buffer a single
line) to a key binding then the behaviour will be like this: initial press
scrolls one line. Then there is a long delay. After that a single line is
scrolled with very short delays. It is controlled entirely by how key
repeat works in the OS. Getting rid of the initial long delay or
controlling the repeat interval is impossible.

In my initial search for this feature I came across a bunch of
StackOverflow questions that also asked for behaviour that would require
this functionality. Often the best answer was to use key-chords. But the
semantics of pressing two keys quickly after each other is quite different
from the press-and-hold semantics of a modifier.

Thank you for considering this.

Kind regards
Simon Friis Vindum

[-- Attachment #2: Type: text/html, Size: 2466 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22163: Feature request: Add support for key release event
  2015-12-13  8:58 bug#22163: Feature request: Add support for key release event Simon Friis Vindum
@ 2015-12-14 22:17 ` John Wiegley
  2015-12-15 20:15 ` Simon Friis Vindum
  1 sibling, 0 replies; 4+ messages in thread
From: John Wiegley @ 2015-12-14 22:17 UTC (permalink / raw)
  To: Simon Friis Vindum; +Cc: 22163

>>>>> Simon Friis Vindum <simonfv@gmail.com> writes:

> It should be possible to bind functions to the _release_ of a key.

Those who understand the fundamentals of event handling would know better, but
doing this right could be a rather invasive change. For example: Should
`read-event' return once a key is pressed down; or should it wait until the
key has been released, and then also give both the press-down and release
times? At the moment, it just notifies the user of the key?

Because once you have sensitive to "length of press", I imagine that's just
the start of additional information you'd want about events and how they
relate in time to each other...

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22163: Feature request: Add support for key release event
  2015-12-13  8:58 bug#22163: Feature request: Add support for key release event Simon Friis Vindum
  2015-12-14 22:17 ` John Wiegley
@ 2015-12-15 20:15 ` Simon Friis Vindum
  2015-12-15 20:27   ` John Wiegley
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Friis Vindum @ 2015-12-15 20:15 UTC (permalink / raw)
  To: 22163

>>>>> John Wiegley <address@hidden> writes:

> Those who understand the fundamentals of event handling would know better, but
> doing this right could be a rather invasive change. For example: Should
> `read-event' return once a key is pressed down; or should it wait until the
> key has been released, and then also give both the press-down and release
> times? At the moment, it just notifies the user of the key?

I was thinking that one might define a new built-in function. It could
for instance
be called `define-key-release` and behave exactly like `define-key`
except that the
passed command would be triggered on key release instead of key press.

It seems to me like that would be backwards compatible and non-invasive.

> Because once you have sensitive to "length of press", I imagine that's just
> the start of additional information you'd want about events and how they
> relate in time to each other...

I think that if you can get the press and release of a key then you have access
to all information from the hardware. Everything else can be derived from that.

Kind regards
Simon Friis Vindum





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#22163: Feature request: Add support for key release event
  2015-12-15 20:15 ` Simon Friis Vindum
@ 2015-12-15 20:27   ` John Wiegley
  0 siblings, 0 replies; 4+ messages in thread
From: John Wiegley @ 2015-12-15 20:27 UTC (permalink / raw)
  To: Simon Friis Vindum; +Cc: 22163

>>>>> Simon Friis Vindum <simonfv@gmail.com> writes:

> I was thinking that one might define a new built-in function. It could for
> instance be called `define-key-release` and behave exactly like `define-key`
> except that the passed command would be triggered on key release instead of
> key press.
> 
> It seems to me like that would be backwards compatible and non-invasive.

Sure, from the point of view of `define-key', it would be. What I meant is
that key-handling right now is done on the basis of received events, and that
"key pressed down" is not an event. We only have "key pressed".

I don't know how hard it would be to break up key events into multiple phases,
or how backwards compatible it would be to see a union of up/down phases as
equivalent to what we know now as a "key press" event.

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-12-15 20:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-13  8:58 bug#22163: Feature request: Add support for key release event Simon Friis Vindum
2015-12-14 22:17 ` John Wiegley
2015-12-15 20:15 ` Simon Friis Vindum
2015-12-15 20:27   ` John Wiegley

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).