Key remapping software - keyboard

I am searching for a software that is able to remap my keys and can detect when I am holding down a key. I am looking for something like this so I can make a key have two functionalities e.g. Let’s say I want to modify caps lock to behave like an escape when tapped but when you hold it it acts as a modifier key and changes the whole keyboard layout. If I am holding caps lock and press d it performs a Home key press. Do you know of any software that can do that aside autohotkey? The reason I don’t want autohotkey is that I have tried it and made this configuration described but I find that it’s lagging and it’s missing key presses. Sometimes it types the letter I just pressed and others it works but this is really annoying.

Related

How to replace non existing key with software key?

I have a very unusual problem.
I droped my notebook (Asus Zenbook Duo UX482) and needed to replace the Shell. Since the Keyboard is directly built into the shell, I had to buy a complete shell / Keyboard / mouse combinantion.
Problem: I live in Germany (QWERTZ) but the replacement part was only available in QWERTY. No problem I thought, just swap the keycaps. That has worked for every key, exept one.
With QWERTZ there is a key for >;<;|. This is located to the right of the left shift key.
With QWERTY, this key just does not exist.
Now on one hand, I want to stay with QWERTZ, since all my desktop Keyboards are QWERTZ.
On the other hand are those three symbols really important for programming, and I dont want to paste them into the code every time I need them.
Is there some kind of software solution for that?
I cannot just type in the ASCII code, since this Notebook does not have a numpad (is there a way around that?).
My last option would be to tear down the notebook again and switch the keyboard part of the shell, but I really dont want to do that, because the backlight layer is directly glued to the membrane layer, and I would need to peel it away to get to all the screws.
Thank you for your help!
I tried to insert the ASCII code with holding ALT pressed, but as I mentioned, that does not work, since the Notebook does not feature a numpad.

Why are h,j,k,l recommended over using arrow keys for vim?

I am a vim user (not a beginner not advanced). I use the arrow keys.
I have repeatedly read that it is highly recommended to use the h,j,k,l keys for increased productivity.
I have tried to use them but I can not see how they help in being more productive.
Because if I am to use the h,j,k,l keys to move up/down/right/left I need to press the ESC first to exit the insert mode.
But that defeats the purpose doesn't it? Since the original idea is that you don't need to move your fingers away.
If I am to press ESC I might as well be using the arrow keys and save a keystroke.
Perhaps I am doing something wrong here?
Old terminal keyboards like the ADM-3A terminal didn't have arrow keys.
The keyboard layout looked like this and it already had the arrows for hjkl. (By the way, also note the relation between ~ and Home key)
I think it is mainly for historical reasons that vim still uses it (and many are used to it). Perhaps also because many sysadmins are nostalgic about stuff from the 70/80's, and because they can brag about how they can type faster (like typing is the cause of slow coding...).
The distinguishing feature of vi / Vim is that it's mode-based. That means:
you only stay in insert mode for short bursts of typing
in the other modes (mostly normal mode), you have all key [combinations] available for powerful editing commands (which are highly regular in Vim, and can be combined to great effect)
So, it's crucial that you can switch modes easily. For many users, that means remapping the Esc key to a more convenient location (replacing Caps Lock or Ctrl). Then, using H J K L for navigation (note those are only the basics, and it's often better to use more specific motions like w or f{char}) is quicker, because your fingers can stay on the home row (assuming you're a touch typist, which you should invest in if you spend considerable time with a computer). The cursor keys are located so far off that switching there takes too much time (using the mouse is even worse), and isn't good for your wrists, neither.
The problem with the arrows is not that they are too far: the problem is that they only allow you to move character-by-character and line-by-line. And guess what? That is exactly what hjkl do. The only benefit of hjkl over the arrows is that it saves that slight movement of the arm to and from the arrows. Whether you think that benefit is worth the trouble is your call. In my opinion, it isn't.
hjkl are only marginally better than the arrows while Vim's more advanced motions, bBeEwWfFtT,;/?^$ and so on, offer a huge advantage over the arrows and hjkl.
FWIW, I use the arrows for small movements, in normal and insert mode, and the advanced motions above for larger motions.
mouse-using sucker everyone laughs at: (move)↓↓↓↓↓↓↓↓↓↓→→→→→(move)
hjkl-obsessed hipster: jjjjjjjjjjlllll
efficient vimmer: /fo<CR>
h, j, k, and l are on the home row. If you move your hand to use the arrow keys, you have to readjust when you're done with the arrow keys. This is only a problem for touch typists (which everyone back in the day was).
If you like using the arrow keys, by all means, use them. There is one advantage I see over hjkl: arrow keys work in insert mode. Others prefer to move their fingers only minimally. That's a good argument if you are a touch typist and need to type lots of text. At least for me, my thinking is always slower than my editing, so typing speed and minimal finger movement are not so much an issue to me.
In the end, it's a pretty subjective matter. Use what works for you but try to look around and extend your horizon now and then.
h j k l are a stepping stone to more powerful features. Do you really think that left, right, up, down is as advanced as moving the cursor gets in the 21st Century (or 1976)?
Please note that arrow keys are not recorded while using "q" macros, and bring a lot of sheanigans when you are using some esoteric options because arrows interrupt them. The idea with vim is to end up using composable actions as often as possible and arrows are not.
Besides it doesn't make much of a difference anyway. I had the same strule as a kid switching arrows for WASD, once you get used to it it's just another way, closer to where your hand already is.
And it's not just vim, you would not believe how convenient it is to go the extra mile and learn the terminal shortcuts for movement, copy-paste, history, etc. My laptop's arrows broke last year and I couldn't find the time to solve the issue (Amazon reach the space, but not the island where I live). It was a blessing. Now I rarely use arrows anymore, because ctrl-p/ctrl-n/ctrl-b/ctrl-f/etc. it's just more ergonomic. I just lay my hands on top of the keyboard and don't move them anymore. Ironically now the fartest I move my hands from standard position is to press ESC, wich happens quite often in vim.
A few times I've heard "wait, your terminal/editor can do what!?" when doing fancy things with public. Probably their toolset can do it too, but they haven't go the extra mile of truly learning them. Trust me, it's worthwhile to do so. These tools have been designed this way for a reason.

On linux, can I get keys to behave differently if tapped?

So I just read a wonderful article about tricking out the modern keyboard:
http://stevelosh.com/blog/2012/10/a-modern-space-cadet/
On of the most interesting suggestions for me is this vision of a duality for the control key:
When pressed in conjunction with another key, the control key acts as it normally does.
When briefly tapped, the control key sends escape.
This would be a big deal for me, because it would save me a significant amount of movement as I use vim.
Is there any way I can implement this behavior in linux?
https://github.com/alols/xcape Xcape seems to be exactly what you're after.

Map keyboard for common paste operation

I want to program a key on my keyboard to paste certain static text when pressed.
For instance, I'd like to program the F12 key so, when pressed, it pastes my email address every time. Is there an easy way to do this?
There are some excellent free software products that allow you to remap keys and create macros. For Windows, you can use AutoHotKey. I've used it before and it can be quite handy for this sort of thing.
It's a very powerful tool and can be a little intimidating to use at first but it's worth taking the time to get to know it. The Quick Start guide is quite helpful.
If you mean instead, the ability to do this within your own program using C++ or .NET or something, give some more details.

Is it worth swapping Ctrl and Caps Lock for windows users that don't use Emacs

I've been aware of Steve Yegge's advice to swap Ctrl and Caps Lock for a while now, although I don't use Emacs. I've just tried swapping them over as an experiment and I'm finding it difficult to adjust. There are several shortcuts that are second nature to me now and I hadn't realised quite how ingrained they are in how I use the keyboard.
In particular, I keep going to the old Ctrl key for Ctrl+Z (undo), and for cut, copy & paste operations (Ctrl+ X, C and V). Experimenting with going from the home position to Ctrl+Z I don't know which finger to put on Z, as it feels awkward with either my ring, middle or index finger. Is this something I'll get used to the same way I've got used to the original position and I should just give it time or is this arrangement not suited to windows keyboard shortcuts.
I'd be interested to hear from people who have successfully made the transition as well as those who have tried it and move back, but particularly from people who were doing it on windows.
Will it lead to any improvement in my typing speed or comfort when typing.
Do you have any tips for finger positions or typing training to speed up the transition.
I actually don't swap control and caps and just make caps ANOTHER control key. I can't think of a single time in my life when I have ever hit caps-lock on purpose, so I haven't missed it.
That way, you get used to using it, but if you slip up and use the old control, things still work. It's worked out very well for me.
There's a .reg file to do this here.
I've done it for quite a while now, and it's natural to me, even though I'm not an Emacs user either (I'm in the Vim camp of that particular war :) ). In fact, it's so natural that moving to other machines (coworkers, family members, etc.) causes me grief because Ctrl isn't where it 'ought' to be.
For emacs ctrl should be at caps lock - for vim the escape key should be on the caps lock. I really feel that the caps lock button should be renamed "free parking" and OSes should make a system tray utility to quickly change the free parking button from escape, to control, to anything you need to type over and over again.
I ended up taking the advice in Zach's answer, but I also made Caps Lock behave as an ESC key if it was held and released on it's own using the AutoHotKey script in this gist: CapsLockCtrlEscape.ahk
I also bound Ctrl+Shift+Caps Lock to Caps Lock for the rare occasions when I might need it using this AutoHotKey script:
#IfWinActive
^+Capslock::Capslock ; make CTRL+SHIFT+Caps-Lock the Caps Lock toggle
return
I switched the Caps Lock and Ctrl keys a couple of months ago and after the initial learning period, ~ 1 week, my biggest problem is when I use a computer that hasn't switched the keys.
I first did some registry hack but I can't remember where I found the information on how to do it. Now I'm using a small utility called Remapkey which is included in the Windows Server 2003 Resource Kit Tools even though I think I'm using an older version.
I had no problem making the transition. I use keyboards with both configurations without issue. Perhaps having it as a hardware solution (and the labels properly printed) makes it easier than doing it through software and having to remember how each machine/keyboard is setup.
I think what's best to put on caps depends on your physical keyboard.
At home I type on a Kinesis Ergo Elan where my ctrl keys are under my thumbs, along with 2*alt, space, enter, backspace, delete, pgup, pgdn, home and end; the rest of the keyboard is fairly normally laid out, except the board is split.
With the ctrl keys ready at hand, it really makes the most sense to put escape on caps lock (and caps lock on esc, for the few times I need it). Even if you're an emacser, hey... it doubles as a spare "prefix alt key", and you probably ask your browser to stop what it's doing a few times every day.
On the other hand, if I'm typing on my laptop where the lower left corner key is Fn rather than ctrl (ffs...) and I can't hold down shift+ctrl with one finger, it might make sense to put ctrl on caps (such that I can hold them with a single finger). At least if you're not a vi'er, or you don't mind the escape key being further away (or have some crazy system).
What's really interesting is putting some funky key on shift+shift (yep, both shift keys). This can be done with xmodmap fairly straightforwardly; I put my compose key there. If you don't need compose, you may want to put something else (like, say, esc).
Copy the following code into a file called caps-ctrl-swap.reg, execute the file, agree to allow registry to be changed, log out and back in and your caps-lock and left-ctrl keys will be swapped. I've used this script for whatever version of Windows was current in 2005 and every version in between. I needed it today since Windows 10 updated overnight and it still works great.
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00

Resources