how do i make UIKeyInput make repeated deleteBackwards calls
Asked Answered
K

2

8

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?

Knoll answered 6/7, 2011 at 4:26 Comment(1)
Did you get anywhere with this issue?Anaphora
I
3

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

Inception answered 12/5, 2012 at 9:55 Comment(0)
J
3

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.

Jumbo answered 7/5, 2012 at 20:10 Comment(0)
I
3

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

Inception answered 12/5, 2012 at 9:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.