# DVORAK Keyboard layout

Here's an interesting challenge...

I want you to golf code than 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)

In comparison, here is the standard US QWERTY layout:

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...

• I think you need to specify a standard QWERTY layout if you want this to be a fair challenge. I suggest using this one. – squeamish ossifrage Mar 3 '14 at 12:09
• @JanDvorak We are waiting for your solution ;) – VisioN Mar 3 '14 at 12:29
• 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? – fejesjoco Mar 3 '14 at 13:03
• @fejesjoco are you referring to the last sentence? I read that as "STDIN must be read from and STDOUT written to without buffering" – John Dvorak Mar 3 '14 at 13:41
• 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? – 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.

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

# C - 144 characters

main(c){putch((c=getch())>33?c:"_#\$%&-()*}w[vz0123456789SsW]VZ@AXJE>UIDCHTNMBRL\"POYGK<QF:/\\
=^{axje.uidchtnmbrl'poygk,qf?|+~"[c-34]);main(0);}

• Nice solution ;-) – 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

-::[
=::]
q::'
w::,
e::.
r::p
t::y
y::f
u::g
i::c
o::r
p::l
[::/
]::=
s::o
d::e
f::u
g::i
h::d
j::h
k::t
l::n
;::s
'::-
z::;
x::q
c::j
v::k
b::x
n::b
,::w
.::v
/::z


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

• Shouldn't there be a "return"? – MilkyWay90 Dec 9 '18 at 20:38
• @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. – tsh Dec 10 '18 at 2:13
• Oh okay thank you for the explanation. – MilkyWay90 Dec 10 '18 at 3:25

# R, 157 bytes

Simple translate script.

chartr('\'qQwWeErRtTyYuUiIoOpP[{]}sSdDfFgGhHjJkKlL;:"zZxXcCvVbBnN,<.>/?=_+-','-\'",<.>pPyYfFgGcCrRlL/?=+oOeEuUiIdDhHtTnNsS_;:qQjJkKxXbBwWvVzZ{]}[',scan(,''))
`

Try it online!