Dvorak Key Configration Transformer

I learned using the Dvorak keyboard a good while ago, and when I jumped back to blending I found the constant switching between Qwerty (for sane hot keys) and Dvorak (for sane writing) annoying.

So I’ve cooked up a script to transform an existing Qwerty key configuration to one that responds to the same keys in Dvorak. The conversion map included in this script is tailored to converting the Norwegain Qwerty variant to the Norwegain Dvorak variant, and may need some adjustments in order to properly transform other variants of Qwerty to Dvorak.

If you have a custom key configuration I advice backing it up before trying to run this script, as it may end up badly scrambling your key configuration.

Usage is simple, copy the script below into a text block in Blender and run it. It will convert the current keymap and prompt for a name to save it as. After that you can load your default startup file, change the input preset in the user properties to what you just saved the keymap as, and then save the startup file.

Do not run this script twice in a row, it will scramble the key configuration. If you need to test adjustments to the conversion map, save the blend file with the script in it and restart blender between every time you try running it. It’s not requried to enter anything in the input box that saves the key configuration, which appears when running the script, it’s there for the convenience of properly saving the key configuration after it’s been converted.

# Copyright 2015 Julian Sivertsen

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation. See <http://www.gnu.org/licenses/>.


import bpy


# Mapping between the Qwerty keys, and what keys they are replaced with
# when using Dvorak. In other words. Label of the key on the keyboard
# is on the left, and the key that is registered when pressing that key is
# on the right.

# This particular map is for Norwegain Qwerty to Norwegian Dvorak.
conversion_map = {
    'A': 'A',
    'B': 'X',
    'C': 'J',
    'D': 'E',
    'E': 'PERIOD',
    'F': 'U',
    'G': 'I',
    'H': 'D',
    'I': 'C',
    'J': 'H',
    'K': 'T',
    'L': 'N',
    'M': 'M',
    'N': 'B',
    'O': 'R',
    'P': 'L',
    'Q': 'RIGHT_BRACKET',
    'R': 'P',
    'S': 'O',
    'T': 'Y',
    'U': 'G',
    'V': 'K',
    'W': 'COMMA',
    'X': 'Q',
    'Y': 'F',
    'Z': 'QUOTE',
    'PERIOD': 'V',
    'COMMA': 'W',
    'MINUS': 'Z',
    'SEMI_COLON': 'SEMI_COLON',
    'RIGHT_BRACKET': 'SLASH',
    'ACCENT_GRAVE': 'S',
    'QUOTE': 'MINUS',
    
    # Slash becomes an unbindable key. The unbindable key in turn
    # becomes Accent grave. No support for 105 key keyboards :(
    'SLASH': 'ACCENT_GRAVE',
}


wm = bpy.context.window_manager


# Transform the keys using the conversion_map
for km in wm.keyconfigs.user.keymaps:
    for kmi in km.keymap_items:
        if kmi.key_modifier in conversion_map:
            kmi.key_modifier = conversion_map[kmi.key_modifier]
        
        if kmi.type in conversion_map:
            kmi.type = conversion_map[kmi.type]




# Ask the user for a name to save the preset as
bpy.ops.wm.keyconfig_preset_add('INVOKE_DEFAULT')
1 Like

just a heads up. If you use Linux/KDE it will work it will do this out of the box for you - as in the default behaviour is what you want, no need for the script. (I haven’t found anything that handles non-standard keyboard maps as well as KDE)

This is really interesting, I love the idea.
By the way, where did you learn to type with Dvorak? I am currently on my way and I’m using TypingStudy. However, I’m not sure it’s the best option. What did you do?

@kayoslll: I belive that is a bug in Xkb, but I never investigated it. The same thing happens on GNOME based desktops, but not for GNOME applications.

@mstechreak:
Welcome the Blender Artists Community. For learning Dvorak I ended up with putting an image of the Dvorak layout as a desktop background. I rested my fingers on the home row of the keyboard with the help of the bumps on F and J. And then I wrote text in agony for a month.

I probably shouldn’t wander to much off topic, as this thread is about the script I wrote to convert Qwerty keymaps into Dvorak eqivalents. You might discover other Dvorak useres here if you start a thread in the Off-Topic section. Or you could find a forum for Dvorak users :).

@Cent, thanks a lot :slight_smile: I giggled a bit when you said “And then I wrote text in agony for a month”. I wonder if there is an easy way how you can learn to switch easily from one layout to another.
Thanks again! :slight_smile:

I just want to tell you that I’m loving you in 2019 for doing this script :slight_smile: :heavy_heart_exclamation:

also if you want to learn Dvorak use a typing software like Klavaro