Keyboard Program?

16 views
Skip to first unread message

Paul Boniol

unread,
Feb 28, 2023, 5:26:08 AM2/28/23
to NLUG
Is there something for Linux (gnome) that will work like the Windows Keyboard program, that shows what keys are being pressed on the keyboard? I have some funkyness and wondering if some key(s) periodically get stuck.

I found plenty of keyboard programs to let me click to type, but they don't show depressed keys the system is registering.

---Paul.

Greg Donald

unread,
Feb 28, 2023, 9:22:30 AM2/28/23
to nlug...@googlegroups.com
Here's something you can run in your terminal. Does this help? I can
see repeats when I hold a key down:

https://github.com/gdonald/keyboard
> --
> --
> You received this message because you are subscribed to the Google Groups "NLUG" group.
> To post to this group, send email to nlug...@googlegroups.com
> To unsubscribe from this group, send email to nlug-talk+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/nlug-talk?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups "NLUG" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to nlug-talk+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/nlug-talk/CAL9PgS1wRdjX5euNx9BE9Lvk%2BuewGCtV%3D9dwv37SQXe_geM87A%40mail.gmail.com.



--
Greg Donald

THOMAS BARTKUS

unread,
Mar 4, 2023, 10:22:22 AM3/4/23
to nlug...@googlegroups.com, Paul Boniol
    >> Is there something for Linux (gnome) that will work like the
    >> Windows Keyboard program

Something. Sort of.

There is xev that outputs all input events, both keyboard and mouse. I believe xev is generally available if not already present to all linux distributions.

But "all" input events gives a confusing mess!  To focus on keyboard keys -
You can pipe xref output to grep to isolate keypresses.
------------------------------------------------------------------------
xev | gawk -F"," '/keycode/{if($0!=l)print $2,$3;l=$0;}'
------------------------------------------------------------------------
I would copy and paste that difficult one liner to your shell to see if it serves you.

That grep expression focuses on (I think!) what you want.  It pulls and presents data from the "keycode" lines only.
  • You open xev in a terminal window.
  • Notice that xev opens it's own gui window.
  • xev then outputs all linux input events happening to it's window to your terminal.
  • Events occurring outside the xev window are ignored.
  • The gawk utility ignores (hides) all the action except for key presses.
  • Press {ctrl}c in your terminal to quit xref
  • Higher functions (F1-F12, Print Screen) preempt xev and do their own thing. xev doesn't see these.  Unless, of course, the Fn key does nothing.
The complex grep expression here is almost more than I can handle.  If I needed more polish  I would have to build a python wrapper around xev.  But  it does serve me.  And I don't type that hot mess over and over.  I alias it in my bash shells.

Reply all
Reply to author
Forward
0 new messages