• You are not logged in.

    Keep your QWERTY hotkeys when moving to Colemak

    • Started by Sergey_S
    • 11 Replies:
    • Reputation: 0
    • Registered: 22-Jul-2012
    • Posts: 4

    I wrote this little AHK script for myself, but maybe it will be useful for someone else.
    The biggest challenge in moving towards Colemak for me was the change of hotkeys. It's not just that you have to learn many of them anew (which is also bad), but for people like me, who live in non-Latin-alphabet countries and use localized software, it just turns into a nightmare, since you now have 2 sets of hotkeys in most programs. E.g., if I type in MS Word in English (Colemak), I have to press Ctrl + physical "L" to make text italic. If I type in Russian, I have to press Ctrl + physical "I" to do the same thing. And the program treats these two as the same hotkey, so you can't just remap them.
    To avoid this schizophrenia, I decided to stick to QWERTY hotkeys, which was easy, since i used them automatically anyway.
    For that I wrote a script for AutoHotKey which reverts the keys back to QWERTY when either Ctrl, WinKey or Alt is pressed. So, if you press physical "I" key in Colemak, it will produce "U", but if you press Ctrl + physical "I", it will produce Ctrl-I. Also applies to combinations (e.g. Ctrl-Shift-I). Shift+key still produces capitalized Colemak letters.
    The script's here: https://docs.google.com/open?id=0B8_3FL … ksxLUE2ZkU
    You'll need AutoHotKey to run it, which you can find at https://www.autohotkey.com/.
    It worked fine on my home PC, my laptop and my work PC.
    It's really just a list of key remappings, so hardly anything can go wrong. If it interferes with your work, just disable it.
    Feel free to modify and redistribute it, just give credit where credit is due.
    Cheers!

    Last edited by Sergey_S (22-Jul-2012 20:15:05)
    Offline
    • 0
    • Reputation: 214
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,364

    Hmmm... a thought: If you're using a layout install made in MS Keyboard Layout Creator you could actually remap the Ctrl+key set to the QWERTY ones while keeping the others in Colemak! Can't do Alt mappings that way though.

    Are you saying you remap the shifted letters too? So that when you try to capitalize a letter it turns into a QWERTY mapping? :o

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • Registered: 22-Jul-2012
    • Posts: 4

    No, it doesn't  - only ctrl-shift-something combinations, or shift-alt-something, as it should. Also does WinKey+key combinations. That was a typo on my part. I corrected the original post.

    Last edited by Sergey_S (22-Jul-2012 20:15:39)
    Offline
    • 0
    • Reputation: 0
    • Registered: 22-Jul-2012
    • Posts: 4

    As for the Keyboard Layout Creator, thanks for the suggestion, but it is, as you mention yourself, an incomplete solution. Perhaps, some other ways around this could be found, but I myself already use AHK for other tasks, so this was the path of least resistance for me.

    Offline
    • 0
    • Reputation: 1
    • From: Sofia, Bulgaria
    • Registered: 05-Mar-2011
    • Posts: 387

    I would suggest you my approach (I'm Bulgarian, so I know how you feel). I keep the Colemak shortcuts and instead, I change the ctrl+... keys for the Bulgarian layout, or in other words I've made my own layout for Bulgarian, which matches the Colemak letters the same way the original layout matches QWERTY. I've used Microsoft Keyboard Layout Creator.

    PS: I personally like Colemak better than Qwerty for shortcuts, since I feel P is more valuable than E for shortcuts (and I'm almost never using the defaults anyway ;)

    Last edited by pafkata90 (24-Jul-2012 22:42:04)
    Offline
    • 0
    • Reputation: 0
    • Registered: 22-Jul-2012
    • Posts: 4

    Thanks for the suggestion, really, but again, guys, it's not like I have a problem I cannot solve and I'm asking for advice. On the contrary, I found a solution and decided to share it.
    Even if it is possible, I don't see the point in trying to make my Russian hotkeys like Colemak ones, at least for 2 reasons:
    1) that would mean relearning many hotkeys I've used automatically for years;
    2) that would significantly slow me down on non-Colemak computers (i.e. nearly all other computers, and I do have to work on them sometimes, and in the presence of my colleagues as well). It's bad enough that I now can't type fast in QWERTY, which makes me look somewhat unprofessional. Fumbling for age-old hotkeys would be really embarassing...
    And, besides, why do that at all? I don't remember hotkeys by their letter (not the ones I use frequently, anyway). I use them automatically, so it's no difference to me if it's Ctrl-I or Ctrl-U, if it does what I want. My fingers do the remembering for me.

    Offline
    • 0
    • Reputation: 214
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,364

    Haha, sorry if we're being busybodies! :) That's the flipside of great enthusiasm you're seeing.

    Different users will have different opinions on what's the most consistent and logical placement of hotkeys is. For me it's easier and more logical to go by letter mnemonics than by position - as long as those are making sense to me in the first place. I've already learnt to type in another layout so a few hotkeys are a piece of cake to me. YMMV.

    Last edited by DreymaR (25-Jul-2012 19:11:03)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • From: Minsk, Belarus
    • Registered: 27-Sep-2012
    • Posts: 5

    I personally think, just like pafkata90, that keyboard shortcuts should be meaningful, so I have chosen to modify the hotkeys in the Russian layout after switching to Colemak. However, I have also found out that for a seamless remapping it’s not enough to modify the behaviour of single keystrokes. In Microsoft Word 2007, for instance, it’s possible to press ‘Alt+F’, then ‘O’ (or even ‘Alt’, then ‘F’, then ‘O’) to launch the Open File dialog. This is designed to work under both English and Russian keyboard layouts, and that’s definitely a very convenient feature. But it does not work with Colemak out of the box, and it’s hard to keep track of whether the Ribbon interface (or whatever) is currently active.

    The solution that I have settled with is to use registry remapping to install the Colemak layout, and then modify the normal Russian layout with Microsoft Keyboard Layout Creator in order to return its messed letters into their customary positions. That is, I’ve rearranged the Russian keys themselves, without introducing extra ‘Ctrl+’ keystrokes. The same thing may be done with any other layout (including the standard QWERTY one). Indeed, such an approach requires a modified version of the Colemak layout itself to be created as well, if we want to use its international capabilities (I personally haven’t done that, because I use my own Alt Gr key extensions in both English and Russian, and now they all are working). Now I have a truly hard-coded layout, and my Microsoft Word interface works identically in Colemak and Russian.

    I have to admit, however, that my approach won’t work with complicated input methods, like those used in Asia, that may not be emulated with MSKLC (for instance, Japanese kana and Chinese bopomofo).

    Last edited by JanK (29-Sep-2012 12:09:28)
    Offline
    • 0
    • Reputation: 0
    • From: Minsk, Belarus
    • Registered: 27-Sep-2012
    • Posts: 5

    Here is a Python scipt that makes it possible to modify an existing keyboard layout so that it could be used with the registry-remapped Colemak:

    #File name: 'colemakScRemap.py'
    
    import sys
    
    assert len(sys.argv) == 3, ('Usage: "python colemakScRemap.py '
        '<input klc file path> <output klc file path>"')
    
    srcFilePath = sys.argv[1]
    dstFilePath = sys.argv[2]
    
    assert srcFilePath.endswith('.klc') and dstFilePath.endswith('.klc')
    
    scanCodeMap = {
        '12' : '21',
        '13' : '19',
        '14' : '22',
        '15' : '24',
        '16' : '26',
        '17' : '16',
        '18' : '15',
        '19' : '27',
        '1f' : '13',
        '20' : '1f',
        '21' : '14',
        '22' : '20',
        '24' : '31',
        '25' : '12',
        '26' : '17',
        '27' : '18',
        '31' : '25',
    }
    
    with open(srcFilePath, encoding = 'utf16') as srcFile:
        with open(dstFilePath, 'w', encoding = 'utf16') as dstFile:
            
            for line in srcFile:
                
                for key in scanCodeMap:
                    if line.startswith(key + '\t'):
                        line = scanCodeMap[key] + line[2 :]
                        break
                
                line = line.replace('- Custom', '- for registry-remapped Colemak')
            
                dstFile.write(line)

    This script will require Python 3.0 or later.

    The algoritm is as follows: launch the Microroft Keyboard Layout Creator; load an existing keyboard; save it into a file; modify the file using the script; load the modified file into MSKLC; build the setup package, and then install the modified layout.

    Disclaimer: just like the registry remapping technique itself, this is a hack. Actually, the problem is that sometimes we would like to conwert letters of one alphabet (or just the keyboard scan codes) into letters of another one. But in order to to so, we need to know the layout for the destination alphabet. Ideally, there should be a way of specifying the default layout for any of the possible alphabets (Latin/Cyrillic/Greek/Hebrew/etc). But I'm not sure if there exists an operating system that provides a functionality of specifying default layouts for alphabets.

    Last edited by JanK (29-Sep-2012 18:51:09)
    Offline
    • 0
    • Reputation: 214
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,364

    Fun with scripts! :)

    The registry remapping method isn't a hack. It's a modification on a lower level. That level should reflect the "physical" layout of your keyboard, so if your machine only ever will use Colemak for instance and has the key caps moved to reflect this then I'd say it's the most natural option. As you've noted, then every layout you put on top of that will reflect this "physical" reality.

    As you say, the OSes have been torn regarding how to define layouts and IMEs. Microsoft has left this to each country to define, but then the Uighurs and other groups are in trouble because they don't have any nations to speak up for them! :( Beyond the main scripts/alphabets there's often a certain national complexity: In Norway we use the æøå letters, in Sweden the same letters are writtten äöå; in Belarus there's some differences from Russian Kyrillic if I remember correctly? So it would make sense but not 100 % to link layouts to countries.

    [edited out a misunderstanding about Belarussian - thanks to JanK for clearing that up!]

    Last edited by DreymaR (29-Sep-2012 21:53:02)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • From: Minsk, Belarus
    • Registered: 27-Sep-2012
    • Posts: 5

    I have discovered that my previous script actually doesn’t solve the problem with hotkeys. It just allows keyboard layouts different from the standard “US” one (including the “Colemak Multilingual” layout itself) to be used on systems where registry remapping technique had been applied. That script remaps the key scan codes, whereas in order for the hotkeys to work in non-latin layouts, we have to modify virtual key codes as well. So here are two more scripts:

    #File name: 'colemakVkRemap.py'
    
    import sys
    
    assert len(sys.argv) == 3, ('Usage: "python colemakVkRemap.py '
        '<input klc file path> <output klc file path>"')
    
    srcFilePath = sys.argv[1]
    dstFilePath = sys.argv[2]
    
    assert srcFilePath.endswith('.klc') and dstFilePath.endswith('.klc')
    
    virtualKeyMap = {
        'E' : 'F',
        'R' : 'P',
        'T' : 'G',
        'Y' : 'J',
        'U' : 'L',
        'I' : 'U',
        'O' : 'Y',
        'P' : 'OEM_1',
        'S' : 'R',
        'D' : 'S',
        'F' : 'T',
        'G' : 'D',
        'J' : 'N',
        'K' : 'E',
        'L' : 'I',
        'OEM_1' : 'O',
        'N' : 'K',
    }
    
    with open(srcFilePath, encoding = 'utf16') as srcFile:
        with open(dstFilePath, 'w', encoding = 'utf16') as dstFile:
            
            for line in srcFile:
                
                for key in virtualKeyMap:
                    if line[2 :].startswith('\t' + key + '\t'):
                        line = (line[0 : 3] + virtualKeyMap[key] + 
                            line[3 + len(key) :])
                        break
                
                line = line.replace('- Custom', '- Colemak-remapped')
            
                dstFile.write(line)

    This script modifies virtual key codes, but leaves scan codes intact. It probably implements the approach taken by pafkata90. It is intended for those users of non-latin layouts that are not using the registry remapping.

    I have tried this approach with Microsoft Word under a Russian layout, and it seems that everything is working just the way I need (that is, both Ctrl and Alt key combinations, as well as hotkeys in the Ribbon interface, work identically to the Colemak layout). So I’ll probably stick to this very solution instead of the registry remapping that I’ve been using recently.

    #File name: 'colemakVkScRemap.py'
    
    import sys
    
    assert len(sys.argv) == 3, ('Usage: "python colemakVkScRemap.py '
        '<input klc file path> <output klc file path>"')
    
    srcFilePath = sys.argv[1]
    dstFilePath = sys.argv[2]
    
    assert srcFilePath.endswith('.klc') and dstFilePath.endswith('.klc')
    
    virtualKeyMap = {
        'E' : 'F',
        'R' : 'P',
        'T' : 'G',
        'Y' : 'J',
        'U' : 'L',
        'I' : 'U',
        'O' : 'Y',
        'P' : 'OEM_1',
        'S' : 'R',
        'D' : 'S',
        'F' : 'T',
        'G' : 'D',
        'J' : 'N',
        'K' : 'E',
        'L' : 'I',
        'OEM_1' : 'O',
        'N' : 'K',
    }
    
    scanCodeMap = {
        '12' : '21',
        '13' : '19',
        '14' : '22',
        '15' : '24',
        '16' : '26',
        '17' : '16',
        '18' : '15',
        '19' : '27',
        '1f' : '13',
        '20' : '1f',
        '21' : '14',
        '22' : '20',
        '24' : '31',
        '25' : '12',
        '26' : '17',
        '27' : '18',
        '31' : '25',
    }
    
    with open(srcFilePath, encoding = 'utf16') as srcFile:
        with open(dstFilePath, 'w', encoding = 'utf16') as dstFile:
            
            for line in srcFile:
                
                for key in virtualKeyMap:
                    if line[2 :].startswith('\t' + key + '\t'):
                        line = (line[0 : 3] + virtualKeyMap[key] + 
                            line[3 + len(key) :])
                        break
                
                for key in scanCodeMap:
                    if line.startswith(key + '\t'):
                        line = scanCodeMap[key] + line[2 :]
                        break
                
                line = line.replace('- Custom', '- for registry-remapped Colemak')
            
                dstFile.write(line)

    This script modifies both scan codes and virtual keys. It is intended for those people who use registry remapping and want to use existing non-latin layouts with hotkeys mapped to the Colemak layout.

    Last edited by JanK (29-Sep-2012 20:11:58)
    Offline
    • 0
    • Reputation: 0
    • From: Minsk, Belarus
    • Registered: 27-Sep-2012
    • Posts: 5

    To DreymaR:

    In Belarusian language, we have ў and і letters that are absent in Russian, and also the apostrophe, but don’t use Russian и, ъ, and щ letters; in Ukranian, there are і, ї, є, and ґ letters, and the apostrophe as well, but Russian ы, ъ, э, and ё are absent. Keyboard layouts for Belarusian and Ukranian are essentially very slight modifications of the Russian one: they replace the unused Russian letters with local ones. All the three layouts are Cyrillic ones. In Bulgaria, on the other hand, the layout is entirely different from Russian, but it is still Cyrillic. In Russia, there is a really large number of national languages (based on cyrillic alphabet), but they are rather rarely used and still lack official keyboard layout support from the OS vendors.

    Last edited by JanK (29-Sep-2012 21:32:59)
    Offline
    • 0