keyboard

I’m not sure how I’d ask “which key is it closest to” without computing distance, or some approximation thereof. In the end, I have a x,y coordinate (the touch) and a bucket of x,y,radius (or x1,y1,x2,y2) sets I have to compare them to. I can see how I could avoid some multiplies with rectangles, but not how I could avoid iterating thru the keys and calculating distance in some manner.

With the rectangles, your code is:

a = math.floor(y/rowHeight) - firstRowHeight
b = math.floor(x/columnWidth) - firstColumnWidth + (a%2)*offset
letter = key[a][b]

where key is a table of keys indexed by row and then position-in-row. Needs a little adaptation for the “special” keys, but otherwise that’s it.

Hmm - ok, I see what you’re suggesting. That makes sense - special keys would simply be multiple entries in the table. That sounds straightforward to my sleep-addled mind.