Write, dammit

October 11, 2010 8:56:37 PM CDT

Got some software today, rather than hardware.

It's a little toy I've wanted to play with for years, and finally got around to coding: a digital typewriter.

Note that I did not say 'text editor'. This is the exact opposite of a text editor. It's a write-once keystroke capture utility, with no editing capacity whatsoever.


Why would anyone want such a thing? Well, there's a difference between 'writing' and 'editing'.

When you edit text, you start with a page full of words and replace it with a marginally different page full of words. Then you do it again. And again. And again and again and again.

When you write, you start with and empty page and replace it with a page full of words. As Gene Fowler once put it, "Writing is easy. All you do is stare at a blank sheet of paper until drops of blood form on your forehead."

The point is that 'editing' is a whole lot easier than 'writing'. It's so much easier, in fact, that editing can become a trap that keeps you from writing.

Many professional writers know this, and refuse to write on a computer because of it. They don't see a text editor as a useful tool, they see it as a toy store full of excuses to do anything but wrestle that next idea into a form that will work on the page.

Instead, they use write-only media like a pen and notepad, or a typewriter. Those force you to move forward by the simple expedient of not giving you any way to go back. They also guarantee that the number of original words you've put on the page will only increase.

So that's what I've built here: you open the page, you start typing.

There's no insertion point, no selection, no backspace, and no delete. Once you hit a key, the character goes down on the page. And it stays there.

If your typing is anything like mine, your first few tries with the thing will be humiliating. I was embarrassed to see how bad my keying skills were without the ability to backspace and delete.

By that standard alone, the thing has repaid the effort I put into writing it (about two hours). I'm already becoming a better and more careful typist. I'm hitting the keys a little slower these days, but making up for it by not having to go back and re-type every third word.

I've even started to play a little game with myself, seeing how many keystrokes I can go between typos. I refuse to announce my current score publicly, but will say that it's getting better every day.

Even with the tool's limited feature set, I couldn't resist a bit of gold-plating. The script creates a new paragraph every time you hit the return key (within limits.. it won't create empty paragraphs), so I had to do a small amount of HTML formatting to make everything work on the page.

Since the HTML already exists, I addded the textarea on the right to display it. You can select the contents of the textarea with your mouse, and copy it from the menu. Keyboard shortcuts won't do you any good, though.

Once I had the HTML, I decided to split the text into sentences for ease of editing later. What you see in the textarea is my preferred format for text markup. Making it work took a small amount of extra work, mostly to avoid ugly effects from unnecessary whitespace. Even so, the whole thing runs from a state machine with four tokens and three states.

By the way, the script treats the delete key as identical to the return key. Hitting either one will generate a new paragraph.

That isn't a bug. It's a design choice.

The whole point of the tool is that you can't delete anything. As such, it's designed to break that automatic habit of hitting delete every time you press the wrong key. The amount of frustration you feel from running into that feature is proportional to the amount of muscle memory you've acquired for bad typing habits.

I've tested the page in Safari, Chrome, and Firefox, and really couldn't care less whether it works in IE. Everything works smoothly in Safari and Chrome, and the only problem with Firefox is that the browser continually butts in to 'help' you when it sees a sequence of characters it doesn't like.

But that's a screed for another day..

Gallery: