Rubygame 3: Day 39

A bit early to be posting about day 39 (it's only 8AM on said day), but I need to think through what I'm working on now, and writing about it has proven to be a good way of doing that.

I'm doing some filtering of keyboard event names to make them prettier symbols. I've already changed from integer constants like K_QUOTEDBL to symbols like :"\"". But how horribly unreadable is that?

In addition to the troubles with ruby symbols not liking literal punctuation marks (and thus having to put them in quotes), I've also discovered that ruby symbols don't like starting with digits, eithers. Sorry friends, but as cute as it is, :3 is not a valid symbol (:"3" is, though).

So, the question is what to do with these unruly symbols.

For punctuation, it feels natural to me (as an English speaker/writer) is to write out what it's called in English. :comma, :colon, :backslash, :double_quote, and so on. Some of them might get a little wordy (:exclamation_mark, :right_parenthesis), but altogether they're more readable. (Again, that's from an English-speaking perspective. Non-English-speakers are sadly under-represented among the collection of me, myself, and I.)

Numbers are a little different. Somehow it doesn't feel right to write them out as :one, :two, etc. Then there's the difficulty that there are two sets of number keys on a standard English keyboard: the row above the letter keys, and the keypad on the right side. The keypad numbers will probably end up as e.g. :keypad_1. The number row might become :number_1.


Scott Lembcke submitted a comment on #

One thing that I did that worked out pretty well was to allow the use of the character operator (or whatever it’s called). So you could do action(:key_RETURN){…} or action(?a){…}.

That’s one of the handy things about SDL keysyms. The codes for the keys that are in the ASCII set, actually have the ASCII value.

Have something interesting to add to the discussion? Email your thoughtful comments to