8

On my laptop, I'm having a persistent issue where keystrokes on the space bar are being repeated. Having been through a number of replacements, as well as trying multiple operating systems, I have judged that the issue is a hardware one, not a software one.

Fortunately, I learned that Ubuntu had a feature known as bounce keys, which would allow me to counteract the issue, as repeated keystrokes would be filtered.

However, enabling the solution for all keys sometimes filters keys that I don't want to be filtered. For instance, when I type hello, I often press the two ls in quick succession, however sometimes one of the ls is filtered, which can be quite annoying. I know I'll never need to press the space bar twice in such quick succession, and since I'm only having problems with the space bar, I only want to enable bounce keys on the space bar.

So, is it possible to only enable bounce keys on the space bar?

  • Repeated how many times? Does it happen everytime? – daltonfury42 Jul 15 '15 at 5:11
  • It doesn't happen every time, but it's enough to be quite annoying. I'd say that it happens around three times a paragraph. It can be very irritating to have to go back and edit out the extraneous spaces. – Faiz Saleem Jul 15 '15 at 13:03
  • 1
    The space is usually repeated about twice. If you see the source of my original post, you should easily be able to see the repeated spaces, as I've intentionally left them in. – Faiz Saleem Jul 15 '15 at 16:05
  • I have updated my answer, but before reading it, read through this. – daltonfury42 Jul 20 '15 at 6:07
  • Thanks, will try later - I've just been really busy, so haven't had a chance. – Faiz Saleem Jul 21 '15 at 0:22
3
+100

xset - user preference utility for X

r is to control autorepeat.

xset -r 10

will disable autorepeat for the "1" key.

xset r 10

will enable autorepeat for the "1" key.

xset r [keycode]

in my case keycode for space bar is 65 check for yours with code: xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'

Still if you need to change speed of keys you can also use rate parameter to it.

And also add this command to your session start script file.

| improve this answer | |
  • You can get the current list of which keys have autorepeat enabled with xset q. It's a 256 bit array dumped in hex, and quite hard to read. – meuh Jul 18 '15 at 12:14
  • I'll definitely be sure to give this a go. Thanks! – Faiz Saleem Jul 18 '15 at 21:14
  • 1
    Worked fine for me. Enjoy the +100 rep! – Faiz Saleem Jul 21 '15 at 11:58
4

I've found a solution for you, but it doesn't involve Bounce Keys. What I do here is to deactivate the space key/keyboard for a small time each time space is pressed. So here it goes:

We use xbindkeys to capture space bar press (in this case release) and xdotool to insert spaces. Install them if you don't have it on your system:

sudo apt-get install xbindkeys xdotool

A xbindkeys config file should have appeared on your home folder by the name .xbindkeysrc else create one like this:

xbindkeys -d > ~/.xbindkeysrc

Copy the snippet and paste it into your .xbindkeysrc file.

"xdotool key KP_Space; xinput set-int-prop <kbd-id> "Device Enabled" 8 0; sleep .05 ; xinput set-int-prop <kbd-id> "Device Enabled" 8 1"
     m:0x0 + c:65 + Release
    space

Here <kbd-id> is the keyboard ID which can be found out by xinput command. Now you want to configure xbindkeys to start each time you start your computer.

Open /etc/rc.local and add the line xbindkeys before exit 0.

You are done. Open a terminal and type xbindkeys to start it for now. See if it does the job. If it did not catch the double spaces or characters after spaces are missing, adjust the delay in our command in ~/.xbindkeysrc accordingly and reboot.

References:

| improve this answer | |
  • I had a few issues with this answer. The xinput command you linked doesn't disable the keyboard, it disables the touchscreen. I tried to adapt the command to disable the keyboard, but that didn't work either. The correct command is: xinput float 13 ; sleep .1 ; xinput reattach 13 3, which does work. However, the solution itself doesn't work. When I start xbindkeys with this command, the space bar no longer enters a space. It does disable the keyboard briefly, as it should, but no space character is entered. Am I doing something wrong? – Faiz Saleem Jul 17 '15 at 17:58
  • I also just found a way to disable the space key only. It depends on xmodmap: xmodmap -e 'keycode 65=NoSymbol' ; sleep .1; xmodmap -e 'keycode 65=KP_Space – Faiz Saleem Jul 17 '15 at 18:23
  • @FaizSaleem, I am sorry about the first issue, it was my mistake. I gave my keyboard id, which is 10. You can find yours by typing xinput. But we won't need that, you've found a way to disable space alone. – daltonfury42 Jul 18 '15 at 4:14
  • About the second issue, I also only tested only if keyboard is getting deactivated. I tried inserting a space manually using xdotool getactivewindow key KP_Space, but it does not work. – daltonfury42 Jul 18 '15 at 5:05
  • xdotool key space also doesn't work, and every other method I've tried to insert a space has failed. – Faiz Saleem Jul 18 '15 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.