Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do i make UIKeyInput make repeated deleteBackwards calls

Currently I am using UIKeyinput but it is only sending a single delteBackward event even when I hold down the delete key for a long time. How can I make it send me multiple event calls when I hold delete down for a long time?

like image 408
Tom Dev Avatar asked Jul 06 '11 04:07

Tom Dev


2 Answers

There is no easy way to have the system keyboard do auto-repeat. These leaves you with two options:

  1. Fake it by using an overlay on the keyboard (see the comment by @pho0)
  2. Implement a custom keyboard, install it as the inputView for your view or view controller and implement a custom protocol that supports auto-repeat.

Solution 1 works well if you only need the delete key to auto-repeat, but if you need all the keys to auto-repeat the overlay code becomes as complex as the custom keyboard option. (The overlay needs a rectangle for each key, so why not just replace the underlaying keyboard).

Solution 2 involves a certain amount of "up-front" work... One way you might do this is define a key cap class (like a physical key) and a keyboard layout class.

I have implemented both solutions in projects I have worked on, but I currently use solution 2 since I can create whatever keyboard I like. In the simple case the use need never know that it is not the system keyboard. For power users they can customize the keyboard as they see fit.

For what it is worth, I found it useful to have the keyboard class be dumb; it just communicates that a key has transitioned to being down or has transitioned to being up. An additional class above that decides what action should be taken.

In some ways, I know this is not the answer you were looking for, but I hope it helps, IDZ

like image 148
idz Avatar answered Nov 15 '22 18:11

idz


One thing I've seen people do is put a fake button on top of the keyboard button. When someone is holding down on it, have a timer remove the last letter every time it fires.

Hope this helps.

like image 44
pho0 Avatar answered Nov 15 '22 19:11

pho0