Here's an interesting challenge...

I want you to golf code that when executed will allow your input to be converted to mimic output as though you were typing on a DVORAK keyboard layout.

The aim is to mimic the US Simplified Dvorak Keyboard (US:SDK)

enter image description here

In comparison, here is the standard US QWERTY layout:

enter image description here

The keyboard emulation must work for both uppercase and lower case letters as well as shifted keys, for example, if I tapped the q (unshifted) key on my keyboard, the Dvorak code should pop out a ' character on the screen. If I were to tap the c (unshifted) button I should get a j (also unshifted) in response, C (shifted) would get J (shifted) and so on...

I am only concentrating of course on the white keys in the diagram above. Tabs, Caps and the other grey keys should work as per normal...

Any questions? Not for now? Good...

I will not allow external resources that already have the layout encoded already, I will not have any files brought in that can encode the layout. The code MUST be QWERTY INPUT -> (DVORAK RE-CODING) -> DVORAK OUTPUT in nature. No silly Esolangs that are theoretical or just say something like "This program will take QWERTY input and recode it in DVORAK. This is the program." or crap like that... Take this challenge seriously... So Brainfuck coders, I welcome you.

Please note, this is NOT a string conversion program. For every QWERTY key you press, the corresponding DVORAK character must be outputted...

Shortest code wins...

  • 1
    \$\begingroup\$ I think you need to specify a standard QWERTY layout if you want this to be a fair challenge. I suggest using this one. \$\endgroup\$ – r3mainer Mar 3 '14 at 12:09
  • 7
    \$\begingroup\$ @JanDvorak We are waiting for your solution ;) \$\endgroup\$ – VisioN Mar 3 '14 at 12:29
  • 2
    \$\begingroup\$ I don't fully understand. If string manipulation is prohibited, does it mean that stdin is out of the question? So I have to implement some low-level keyboard IO that reads keypresses? This also disqualifies brainfuck, which only reads strings from the stdin. What about stdout, can I send strings to the stdout or do I need to code a keyboard driver of sorts which simulates pressing a different key? \$\endgroup\$ – fejesjoco Mar 3 '14 at 13:03
  • 1
    \$\begingroup\$ @fejesjoco are you referring to the last sentence? I read that as "STDIN must be read from and STDOUT written to without buffering" \$\endgroup\$ – John Dvorak Mar 3 '14 at 13:41
  • 1
    \$\begingroup\$ As an aside, your questions seem to always generate a large discussion in the comment thread. Maybe it is a sign you should be using the sandbox more? \$\endgroup\$ – Tim Seguine Mar 3 '14 at 14:51

Shell: Unix tr(1), 94

tr \''"+-/:-[]_b-{}' "-_}w[vzSsW]VZ@AXJE>UIDCHTNMBRL\"POYGK<QF:/={xje.uidchtnmbrl'poygk,qf;?+"

This command takes QWERTY on stdin and outputs DVORAK on stdout.

  • \$\begingroup\$ Darn, you beat me to it! \$\endgroup\$ – TheDoctor Mar 3 '14 at 15:34
  • \$\begingroup\$ @TheDoctor I just happened on this question early enough ☻ took me a while (about 20 minutes?) to optimise e.g. the ranges, though. \$\endgroup\$ – mirabilos Mar 3 '14 at 15:35

C - 144 characters

  • 1
    \$\begingroup\$ Nice solution ;-) \$\endgroup\$ – mirabilos Mar 3 '14 at 15:35

C#, 360 characters

Probably not the shortest, but it does exactly what you ask:

using System;class A{static void Main(){string[] q={"-=qwertyuiop[]sdfghjkl;'zxcvbnm,./","_+QWERTYUIOP{}SDFGHJKL:\"ZXCVBNM<>?","[]',.pyfgcrl/=oeuidhtns-;qjkxbmwvz","{}\"<>PYFGCRL?+OEUIDHTNS_:QJKXBMWVZ"};while(true){var c=Console.ReadKey(true);var a=c.KeyChar;int i,w=c.Modifiers==ConsoleModifiers.Shift?1:0;Console.Write((i=q[w].IndexOf(a))>-1?q[w+2][i]:a);}}}

If you press a key on your QWERTY keyboard, then the correct DVORAK character appears in the console.


AutoHotKey, 200 bytes


There should be an answer in AHK for this question but not. So just post one.

  • \$\begingroup\$ Shouldn't there be a "return"? \$\endgroup\$ – MilkyWay90 Dec 9 '18 at 20:38
  • \$\begingroup\$ @MilkyWay90 OP didn't ask for halting. And this program will continue run until you manually exit it by clicking tray menu. So, no "return" involved. \$\endgroup\$ – tsh Dec 10 '18 at 2:13
  • \$\begingroup\$ Oh okay thank you for the explanation. \$\endgroup\$ – MilkyWay90 Dec 10 '18 at 3:25

R, 157 bytes

Simple translate script.


Try it online!


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.