USB Keyboard Signals

Hello, I've been using the Dvorak (duh-vor-jok) keyboard layout for some time now, and I was wondering if there was any way that I could build a USB QWERTY-Dvorak keystroke converter. I think I might be able to write a program for this, but, since I have no idea what the keystroke signals are for USB, I can't find a way to take in the keystrokes from the QWERTY keyboard, interpret them, and then output them. Someone please help!

You might be able to do it with a PS/2 keyboard but not for a USB keyboard. Search the forums to find out why.

If you used a PS/2 keyboard you might be able to use AVRUSB to make it act as USB after you converted the codes.


I already know I can do it with a PS/2 Keyboard, this guy managed to do it:

But PS/2 keyboards are getting closer and closer to obsolete, all of the computers at my school have usb keyboards. But that's not all: As most school computers are, the system preferences are locked out, and DeepFreeze is installed on all of them, completely locking me out from accessing any of the keyboard settings.

I could just use PS/2 to USB converters throughout, but I was hoping for a more elegant way to to it. What is AVRUSB? In case you haven't looked at my post count, I am somewhat new to arduino programming, although I'm semi-fluent in the language.

I could just use PS/2 to USB converters throughout, but I was hoping for a more elegant way to to it.

In which case, AFAIK, no, there's not a more elegant way.

What is AVRUSB?

A software low-speed USB client implementation.


The basic problem here is that the USB port on Arduino is not a USB port, but a serial port using a USB plug.

Arduino is not a USB host, and therefore it is very difficult to connect USB HID devices like keyboards , mice and whatever to Arduino.

With AVRUSB some limited succes have been achieved in making Arduino a USB host, but it's very demanding for a little micro like Arduino.

I think the main point is that the additional hardware and the code required would really make this an unattractive solution compared to the software Dvorak translators that are widely available. A hardware solution costing 50, 60, 70, 80 dollars would only be useful if you regularly use other people’s computers every day, and you don’t maintain fluency on QWERTY.

@macegr, The whole reason that I want a hardware converter is that all foreign software on my school's computers is blocked, including programs that you can bring there on your flash drive, cd, etc. And since my school locks out wifi from all foreign computers, too (harsh, I know), I can't access the internet from any computer that I bring there. So in the end, I do have to use their computers a LOT, and I type painfully slow in QWERTY. I've seen AVR USB keyloggers, so the software isn't completely impossible, right? (

There HAS to be some way, although I doubt, by the sound of it, that it would be in the range of my modest programming skills.

Well, just how locked down are your school's computers? If they're Windows machines, they probably already support a Dvorak IME. On XP, try going to Control Panel > Regional and Language Options > Languages > Details. Then hit Add... and choose one of the Dvorak options. C hgoy ece cy br,! (I just tried it).

The computers are completely locked down, and they are macs. The application "System Preferences" is locked out unless you have the administrator password. And it wouldn't even do anything even if I COULD get into the preferences, because DeepFreeze is installed and will revert any changes made to the machine immediately. If I could have changed the preferences, believe me, I would, but I can't, which is why I've posted on these forums for help.

You could suggest switching half of the keyboards to QWERTZ(Y).

Personally I'd be really 'not amused' if I were forced to use anything other than QWERTZ(Y). It's like writing with the untrained other hand. Or maybe propose shifting all deadlines back 2 weeks due to slow typing ;)

Like I said, there's really no other way to go on this. Probably everyone (except me) at my school types in QWERTY, and past attempts at talking to the AV staff at my school have yielded nothing; my school is very paranoid when it comes to technology, they don't want any "footholds" in on the system preferences application. And like I have said before, DeepFreeze reverts the hardware settings anyway.

There HAS to be a hardware, USB solution out there! ...right?

With AVRUSB some limited succes have been achieved in making Arduino a USB host

Actually, AVRUSB does not provide any way to allow the Arduino to act as a host, only as a client.


I feel sympathy for you, but the admins really have no choice than being paranoid about settings and system integrity. This stuff has to work 24/7 for everybody.

I've had this ingrate job for 3 years at university and as soon as you start giving concessions it never stops. I had to deal with windoze clients and that was HELL, even though we used deployment tools and so on. I even tried to make them use a virtualized windows with virtualbox to install their "private tools", but that was not accepted well by the users ("too weird...").

You may have a chance if you poke in the direction of "deep freeze". According to their webpage this system reverts the OS after reboot to its default settings, so no extra work for the admins.

But as soon as admins are afraid of you running any "illegal" code or file sharing servers, we will not give in. Matter of fact.

best of luck ;)

I thank you all very much for your help, but the staff at my school are totally paranoid about [u]any [u]foreign software. I can do it with ps/2, but all of the keyboards are USB. I could use ps/2 to usb converters, but that would be more costly and just doesn't sit right with me... Sigh... I wish there was SOME way to get the signals off of a USB keyboard. Is there a specific byte sent for each letter on the keyboard?[/u][/u]

Is there a specific byte sent for each letter on the keyboard?

Yes (well, sort of), but that’s not the problem. Remember that a single USB port, through appropriate hubs, can have up to 127 peripherals connected to it. It’s the complexity of dealing with the signaling and protocols that implement THAT sort of functionality that make “USB host” impossible to implement on and arduino-class microcontroller system…

Now, my impression is that many USB keyboards also have the ability to speak PS/2, using an adapter that is nothing more than a connector re-formatter (Ie the keyboard detects whether it’s plugged into a usb port or a PS/2 port and speaks the appropriate protocol. The “adapter” doesn’t do anything “smart”; it just puts the wires in appropriate spots.) If that’s the case, you MIGHT be able to have the arduino talk PS/2 to the keyboard (even through a “usb” connector, evil as that might be!), and almost-real-USB to the computer using AVRUSB, and implement your dvorak translator that way. But you’d be looking at a pretty complex project.

Well, a PS/2 to USB Dvorak translator would actually pretty easy. It would really only require an ATTiny45, a mini-DIN connector, a USB cable, and a few small passive components. Actual cost under $15.

Yikes. So in the end, the easiest way would just be to use USB to PS/2 converters from beginning to end? I’m starting to get the idea here, and it sounds a little over my head. :slight_smile:

So in the end, the easiest way would just be to use USB to PS/2 converters from beginning to end?



Probably your best bet with this is to not get involved in the actual USB device/host relationship, and just use serial in and out lines to act as a "man in the middle" device on the wire passing USB serial data from the keyboard to the computer. If you can get it to act as a simple serial repeater, it's a relatively easy step to have it watch for certain byte strings and change them if they correspond to keys you want to change. I made something similar for PS/2 once. USB HID device codes are different from PS/2 scan codes though, so I'm not sure how the codes work. I did find this chart though...

thanks a bundle, jbange!