Text Selection on the iPad

I came across a post on Hacker News yesterday discussing a brilliant new idea for performing cursor movement and text selection on the iPad keyboard, developed by Daniel Hooper. You can see a demo of Daniel’s prototype below:

He’s certainly right that text editing could be made a lot more efficient. Accurate cursor positioning, in particular, is quite difficult with the default iOS mechanism. I already have cursor movement keys in my app like those in IA Writer, but this approach looks even better.

I had a go at implementing this mechanism in UX Write, with partial success:

  • Single-finger cursor movement is fine. You can swipe on the keyboard in any direction to move the cursor, and it moves at one-third of the speed you move your finger, for very precise positioning. Cursor movement only begins once you’ve moved your finger a certain distance away from the original key, so you won’t see it occurring accidentally while you’re simply typing.
  • Two-finger movement is problematic because it conflicts with the built-in iOS split keyboard gesture. I have it working most of the time, but in certain cases the touch events will be interpreted as an attempt by the user to split the keyboard. As in the video, using two fingers allows you to move the cursor faster.
  • Selecting text by holding down shift while you drag with another finger also works most of the time, but in some cases results in extra characters being inserted. With shift pressed, dragging from one key to another causes iOS to highlight the other key and display a list of alternative characters; this doesn’t happen when shift is not pressed. It’s these keys that are causing problems for me at the moment.

My implementation works by intercepting touch events in UIApplication’s sendEvent method, and detecting those which are within the keyboard window. It’s possible to filter out events before passing them on to the application, which might be a solution to the problem.

While I’ve still got some more work to do on two-finger movement and selection, I’m really happy with the cursor movement and think it’s going to make editing a much nicer experience. Daniel has suggested that users petition Apple to include this functionality in iOS itself, but why wait for that? As app developers, we can start implementing this right now. The jailbreak community has in fact just done this, and plans to have it available tomorrow.

I’m going to come back to this in a few days once I’ve finished up table editing and made some more tweaks to the style editor which I want to have in for the next beta, but will post an update with more details once I’ve gotten this all working properly.