Author Topic: Making L_Control act as Backspace when pressed alone  (Read 5314 times)

0 Members and 1 Guest are viewing this topic.

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Making L_Control act as Backspace when pressed alone
« on: Thu, 22 May 2014, 23:57:19 »
[EDIT]
For those not wanted to read the whole thread: Here is the code for the completed modifications in Linux and Windows (Note: you will need xcape for Linux or AutoHotKey for Windows).
(Credit to Eszett for enhancing my original tweak!)

Keyboard features:

Left Control (pressed alone) = Escape
Left Shift (pressed alone) = Delete
Right Shift (pressed alone) = Backspace


Linux using xcape:
Code: [Select]
killall xcape; xcape -e 'Control_L=Escape'; xcape -e 'Shift_L=Delete'; xcape -e 'Shift_R=BackSpace'
Windows using AHK:
Code: [Select]
LControl::
Send {LControl Down}
KeyWait, LControl
Send {LControl Up}
if ( A_PriorKey = "LControl" )
{
    Send {Escape}
}
return
LShift::
Send {LShift Down}
KeyWait, LShift
Send {LShift Up}
if ( A_PriorKey = "LShift" )
{
Send {Delete}
}
Return
RShift::
Send {RShift Down}
KeyWait, RShift
Send {RShift Up}
if ( A_PriorKey = "RShift" )
{
Send {Backspace}
}
Return
[/EDIT]


Original Post below:

Hope this is the right forum to post this in....

Here is an awesome utility to make your Left Control Key (specifically this was tested on a HHKB Pro 2) act as a Backspace character when pressed alone yet retain all other functionality the Control key needs (i.e. CTRL-C, CTRL-V, CTRL-X, etc.).  The command to run in Linux is this:

xcape -e 'Control_L=BackSpace'

In order to get xcape, you need to build it by following the instructions and getting the software from here:

https://github.com/alols/xcape

This can also be done in Windows using AutoHotKey with the following script:

LControl::
Send {LControl Down}
KeyWait, LControl
Send {LControl Up}
if ( A_PriorKey = "LControl" )
{
    Send {Backspace}
}
return

If you don't already have your CapsLock key mapped to Control (which probably you need to do first and foremost!), you will have to first do this (again, using either AutoHotKey for Windows, or xmodmap for Linux).

I can't tell you just how awesome it is to be able to use your left pinky to backspace text while typing instead of reaching over with your right pinky.... Even on the HHKB with its favorable placement of the Backspace key, your pinky has to stretch a considerable distance to reach the backspace.  Having the option to use the LControl key is a huge pinky saver!. 

There are probably a lot of other keymaps that can be done to improve your keyboard layout without sacrificing traditional QWERTY.  If anybody has any other ideas, suggestions, or "wish-lists", let me know and I'll probably be able to point you in the right direction, as this kind of thing is right in my wheelhouse ( I do a lot of system administration - so hacks like this are some of my favorite tricks to do).

Hope this helps someone!
« Last Edit: Sat, 24 May 2014, 07:43:09 by jmolino »

Offline luisbg

  • Posts: 248
  • Location: London
Re: Making L_Control act as Backspace when pressed alone
« Reply #1 on: Fri, 23 May 2014, 00:09:51 »
Cool idea!
Leopold FC660M - Brown mx switches - black case - white blank keys :: ErgoDox - Blue mx switches - classic case - black blank keys

Offline daerid

  • Posts: 4276
  • Location: Denver, CO
    • Rossipedia
Re: Making L_Control act as Backspace when pressed alone
« Reply #2 on: Fri, 23 May 2014, 01:04:26 »
I'll be honest, I'm much more interested in using Escape vs Backspace (heavy vim user)

... which it looks like xcape does by default! Neat.
« Last Edit: Fri, 23 May 2014, 01:12:18 by daerid »

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Making L_Control act as Backspace when pressed alone
« Reply #3 on: Fri, 23 May 2014, 01:14:44 »
I'll be honest, I'm much more interested in using Escape vs Backspace (heavy vim user)

This should work then:

xcape -e 'Control_L=Escape'

(for linux version).  Do you need the AHK script for Windows or are you on linux?

Let me know if you need help setting that up...

P.S. if you are a heavy VIM user do you use Vimium for Chrome?  Its nice (and there is Vimperator and Petadactyl as well.... I just prefer Vimium)...

Offline daerid

  • Posts: 4276
  • Location: Denver, CO
    • Rossipedia
Re: Making L_Control act as Backspace when pressed alone
« Reply #4 on: Fri, 23 May 2014, 01:20:06 »
Yup, been down both those roads a few times now :)

I'm regularly on all 3 big platforms (Win/OSX/Linux).

Offline luisbg

  • Posts: 248
  • Location: London
Re: Making L_Control act as Backspace when pressed alone
« Reply #5 on: Fri, 23 May 2014, 13:39:55 »
Any ideas why when I run:
sudo ./xcape -t 200 -e 'Control_L=BackSpace'

Now the left ctrl removes two characters instead of one? It is like if I were hitting backspace twice.
Leopold FC660M - Brown mx switches - black case - white blank keys :: ErgoDox - Blue mx switches - classic case - black blank keys

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Making L_Control act as Backspace when pressed alone
« Reply #6 on: Fri, 23 May 2014, 15:43:48 »
Any ideas why when I run:
sudo ./xcape -t 200 -e 'Control_L=BackSpace'

Now the left ctrl removes two characters instead of one? It is like if I were hitting backspace twice.

ps -aux

you probably have it running twice...

do a killall xcape to get rid of them and run only 1 instance...

let me know if that works....

Offline luisbg

  • Posts: 248
  • Location: London
Re: Making L_Control act as Backspace when pressed alone
« Reply #7 on: Fri, 23 May 2014, 17:02:55 »
Any ideas why when I run:
sudo ./xcape -t 200 -e 'Control_L=BackSpace'

Now the left ctrl removes two characters instead of one? It is like if I were hitting backspace twice.

ps -aux

you probably have it running twice...

do a killall xcape to get rid of them and run only 1 instance...

let me know if that works....

Cool! I thought it set parameters of the X server and then exited. Didn't it was a process running in the background.

I executed it a bunch of times to get the timing just right.

Kill all the extra processes and now it works well. Thanks!
Leopold FC660M - Brown mx switches - black case - white blank keys :: ErgoDox - Blue mx switches - classic case - black blank keys

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Making L_Control act as Backspace when pressed alone
« Reply #8 on: Fri, 23 May 2014, 17:06:22 »
Any ideas why when I run:
sudo ./xcape -t 200 -e 'Control_L=BackSpace'

Now the left ctrl removes two characters instead of one? It is like if I were hitting backspace twice.

ps -aux

you probably have it running twice...

do a killall xcape to get rid of them and run only 1 instance...

let me know if that works....

Cool! I thought it set parameters of the X server and then exited. Didn't it was a process running in the background.

I executed it a bunch of times to get the timing just right.

Kill all the extra processes and now it works well. Thanks!

Your welcome!  I really love this mod!  I am now backspacing with my left pinky about 90% of the time - and the best part is your hands dont have to move from the home row or even the f and k keys!  great for touch typing!

Offline Smasher816

  • HHKB Master
  • Posts: 538
  • Location: return STATE_MISSOURI;
Re: Making L_Control act as Backspace when pressed alone
« Reply #9 on: Sat, 24 May 2014, 01:42:25 »
I tried turning putting the backspace dual role on my HHKB's control key but could not get used to it. Using Escape like daerid did has been awesome though.

Offline Eszett

  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Making L_Control act as Backspace when pressed alone
« Reply #10 on: Sat, 24 May 2014, 02:08:05 »
Quote
I can't tell you just how awesome it is to be able to use your left pinky to backspace text while typing instead of reaching over with your right pinky....

The basic idea behind it is to let modifiers behave like a normal key if they aren't pressed together with another key. Since I've put Ctrl elsewhere I prefer Shift to do that. And since I have two Shift keys let's go the whole hog and put Delete to LeftShift and and Backspace to RightShift.

Code: [Select]
LShift::
Send {LShift Down}
KeyWait, LShift
Send {LShift Up}
if ( A_PriorKey = "LShift" )
{
Send {Delete}
}
Return
RShift::
Send {RShift Down}
KeyWait, RShift
Send {RShift Up}
if ( A_PriorKey = "RShift" )
{
Send {Backspace}
}
Return
« Last Edit: Sat, 24 May 2014, 04:34:36 by Eszett »

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Making L_Control act as Backspace when pressed alone
« Reply #11 on: Sat, 24 May 2014, 06:49:24 »
Quote
I can't tell you just how awesome it is to be able to use your left pinky to backspace text while typing instead of reaching over with your right pinky....

The basic idea behind it is to let modifiers behave like a normal key if they aren't pressed together with another key. Since I've put Ctrl elsewhere I prefer Shift to do that. And since I have two Shift keys let's go the whole hog and put Delete to LeftShift and and Backspace to RightShift.

Code: [Select]
LShift::
Send {LShift Down}
KeyWait, LShift
Send {LShift Up}
if ( A_PriorKey = "LShift" )
{
Send {Delete}
}
Return
RShift::
Send {RShift Down}
KeyWait, RShift
Send {RShift Up}
if ( A_PriorKey = "RShift" )
{
Send {Backspace}
}
Return

Now we are getting somewhere!!! This is really great! I have to implement this in xcape so the equivalent would be:

Code: [Select]
killall xcape; xcape -e 'Shift_L=Delete'; xcape -e 'Shift_R=BackSpace'
(tested and works great!  FYI - the killall just cleansup the old processes!)

This keyboard layout just WORKS!  and we didn't even have to buy an ErgoDox (which I just did LOL) and/or change from QWERTY!

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Making L_Control act as Backspace when pressed alone
« Reply #12 on: Sat, 24 May 2014, 07:02:33 »
Quote
(tested and works great!  FYI - the killall just cleansup the old processes!)

This keyboard layout just WORKS!  and we didn't even have to buy an ErgoDox (which I just did LOL) and/or change from QWERTY!

And just to have this in a complete code box: Here is the entire code for Linux using xcape:

Left Control (pressed alone) = Escape
Left Shift (pressed alone) = Delete
Right Shift (pressed alone) = Backspace

Code: [Select]
killall xcape; xcape -e 'Control_L=Escape'; xcape -e 'Shift_L=Delete'; xcape -e 'Shift_R=BackSpace'
Now the only thing we need to decide is what to do with the old Delete button above the Return button... hmmm

Offline Eszett

  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Making L_Control act as Backspace when pressed alone
« Reply #13 on: Mon, 26 May 2014, 07:10:04 »
@jmolino The disadvantage of this customization (which is, sending a scancode by releasing a key, not by pressing it) is, that you won't have the "autofire" feature anymore. What if you want to easily erase tons of characters by simply holding backspace (or delete) down? This doesn't work anymore. With some workarounds you could implement the autofire feature again, but only after a fasion, it will be quirky.
« Last Edit: Mon, 26 May 2014, 07:24:49 by Eszett »

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Making L_Control act as Backspace when pressed alone
« Reply #14 on: Mon, 26 May 2014, 08:19:10 »
You are absolutely correct... there is no Key Repeat on the customized keys.  When I want to do a mass Backspace I resort to having to press the original key.

As you say however, there may be a workaround although it inherently won't be perfect - probably something like a delay feature that will send keypressses after x amount of time being held down.  I'm not sure I can make this happen - but I'll try....


@jmolino The disadvantage of this customization (which is, sending a scancode by releasing a key, not by pressing it) is, that you won't have the "autofire" feature anymore. What if you want to easily erase tons of characters by simply holding backspace (or delete) down? This doesn't work anymore. With some workarounds you could implement the autofire feature again, but only after a fasion, it will be quirky.

Offline Eszett

  • Posts: 543
  • Supporting the communities Geekhack & Deskthority
Re: Making L_Control act as Backspace when pressed alone
« Reply #15 on: Tue, 27 May 2014, 07:31:03 »
Exactly.

Offline islisis

  • Posts: 120
  • Location: Tokyo, Japan
Re: Making L_Control act as Backspace when pressed alone
« Reply #16 on: Mon, 02 June 2014, 12:03:49 »
Nice work :)
I really wish this could be implemented in autokey as well. Currently it has no support for binding a key release however.

If you are going to implement keytimer activation it may be worth considering the option to cancel the dual role function.
http://geekhack.org/index.php?topic=41685.0

Offline jmolino

  • Thread Starter
  • Posts: 44
  • Some folks look for answers,others look for fights
Re: Making L_Control act as Backspace when pressed alone
« Reply #17 on: Mon, 02 June 2014, 22:03:15 »
Nice work :)
I really wish this could be implemented in autokey as well. Currently it has no support for binding a key release however.

If you are going to implement keytimer activation it may be worth considering the option to cancel the dual role function.
http://geekhack.org/index.php?topic=41685.0

Thank you for that link! There is a lot of very useful information and links there!  Cheers!