Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard repeat support #32

Closed
bachp opened this issue Oct 12, 2011 · 18 comments
Closed

Keyboard repeat support #32

bachp opened this issue Oct 12, 2011 · 18 comments

Comments

@bachp
Copy link

bachp commented Oct 12, 2011

Hi Mottie,

I thought about a feature that would be nice to have in the keyboard. On physical keyboards the when you hold down a key the keyboard starts repeating this key. It would be nice to have this behavior too. It would be especially useful on touchscreens.

The behavior I thought about would be as follows:
When you start pressing a key the keyboard enters the character once. Then after a certain delay the keyboard starts repeating the character at a certain rate. I think delay and rate should be configurable to the desired time interval/frequency.

Do you already have an Idea how to implement this? Or should I try to come up with something?

Cheers
Pascal

@Mottie
Copy link
Owner

Mottie commented Oct 12, 2011

Hi Pascal-bach!

Hmm, I don't think this is possible to speed up the key repeat rate using javascript. The inherent key repeat rate is set by the operating system. I know in Windows 7, the keyboard properties "Repeat delay" and "Repeat rate" can be set, but as I said javascript isn't this powerful. I did a quick search and found this post on StackOverflow which basically tells me you'll need a desktop application that can change the OS registrry.

What is possible with javascript is to slow down the repeat rate, again a reference to an answer from StackOverflow. But I don't know how useful this might be... If I did include this option with the keyboard, I might just make it into an extension.

@bachp
Copy link
Author

bachp commented Oct 12, 2011

That was not what I meant. The rate from the physical keyboard should not be changed. I meant it should be possible to press a soft key and as long as you don't release the key it should repeat the key according to the options I mentioned.
The whole thing should be independant of a physical keyboard and the OS settings.

I hope I explain it clearer this time. If not please let me know ;)

@Mottie
Copy link
Owner

Mottie commented Oct 12, 2011

Hmm, so I have a question. When you hold down a key on a touchscreen, does the key repeat?

So, basically you want to disable the build-in keyboard key repeat and just make something independent of it? That should be possible, but I won't have time to look into this option until later... busy day today!

@bachp
Copy link
Author

bachp commented Oct 12, 2011

What do you mean by the "build-in keyboard key repeat" ? I dont' think it should be related to the OS settings or the physical keyboard, this would really be most useful on a touchscreen where the onscreen keyboard would behave more like a normal keyboard.

It's not an urgent thing but I think it would be something nice to have.

@Mottie
Copy link
Owner

Mottie commented Oct 12, 2011

Sorry, I was thinking about using the keyboard (keyup/keydown) when I should have been thinking in terms of touchstart/touchend. I don't have an iPad, so I would appreciate it if you could test this demo for me and if it works as you need it to. If you need a full screen version to test on, try this link.

@bachp
Copy link
Author

bachp commented Oct 13, 2011

Yes thats mor what I had in mind. Normal keys are working as expected. However the most useful key to use in this way would be backspace. But backspace and tab are the two that are not working. Any ideas why this could be?

@Mottie
Copy link
Owner

Mottie commented Oct 13, 2011

Ewww, bad bug in that last vesion! Click and release any key quickly and after the initial delay, it just starts typing! LOL.

Ok, try this updated version. I've included the tab, enter, space and backspace keys. But now I see a bug with the enter key (at least in Firefox, ugh).

These demos were more for a proof-of-concept. I think I include this ability in the plugin... I've stopped worrying about the code getting too big from enhancements LOL.

@bachp
Copy link
Author

bachp commented Oct 13, 2011

This is exactly what I thought the keyboard should behave. And I think a plugin for this would be fine.

But there is another bug I recognized. When you press a key and then move the mouse out of the keyboard. The repetition never stops until you close the keyboard.

@Mottie
Copy link
Owner

Mottie commented Oct 13, 2011

LOL, yeah lots of issues still. Try this version... the main problem with this one will be on the touch device, I think. I've made it now so that if you move your finger at all, it cancels the repeat. I had to do this after I read that if you touch a key, then move your finger off of it, the "touchend" event never fires.

Are you able to test this demo on a touch device?

@Mottie
Copy link
Owner

Mottie commented Oct 16, 2011

Ok, this feature was added to version 1.9! It "should" work on touch devices too! :)

@Mottie Mottie closed this as completed Oct 16, 2011
@bachp
Copy link
Author

bachp commented Oct 17, 2011

Nice work. I was able to test it on a touch device and it mostly seems to work. However there are some issues I found. I will try to come up with an example how to reproduce the issues.

@Mottie
Copy link
Owner

Mottie commented Oct 26, 2011

Hi Pascal-Bach!

Were you able to reproduce the issue?

@bachp
Copy link
Author

bachp commented Oct 26, 2011

Hi, sorry for the delay.

I was finally able to reproduce the bug:
http://jsfiddle.net/9JrVf/

  1. Click into the top input field.
  2. Enter a few characters using the mouse.
  3. Hold your mouse down on the backspace key.
  4. Try to enter some more characters. They will immediatly get deleted again.

@Mottie Mottie reopened this Oct 28, 2011
@Mottie
Copy link
Owner

Mottie commented Oct 28, 2011

Ok try version 1.9.2... I've fixed the problem and added enterNavigation to allow navigating between inputs with the enter key

@bachp
Copy link
Author

bachp commented Oct 31, 2011

Hi, I tried 1.9.2 and the problem with the key seems to be gone. Nice work.
However the enterNavigation does not work for me. The base.nextInput function does not find any result.
Is there a way to delegate this to a callback I can override? Because what I would like to do is to submit the form on pressing enter. What do you think?

@Mottie
Copy link
Owner

Mottie commented Oct 31, 2011

So, I think the enterNavigation isn't working because the inputs on your form are most likely wrapped in other elements; I'll fix it to be more reliable. But, should it look for the next input, or the next input with a keyboard attached?

I could add a callback function to override the default behavior of the base.nextInput function, but it would be called after the content was accepted/ignore and the keyboard has closed. Maybe, I could add an "afterClose" callback? Maybe a flag that lets you know it's going to attempt to navigate to the next input?

@bachp
Copy link
Author

bachp commented Nov 2, 2011

I think a callback to override the base.nextInput function is what would do the trick. This would allow me to do the necessary actions when a user presses enter.

The only other possibility would be to create a more generic callback mechanism that allows to override and possibly prevent any keys default action. Using this I could catch the enter key before any action is taken.

@Mottie
Copy link
Owner

Mottie commented Nov 25, 2011

Ok, this issue should be fixed in v1.9.3.

I've also added a callback override as you requested, named switchInput which is added in the options. I've also improved the code that switches between inputs, so that should work better.

@Mottie Mottie closed this as completed Nov 25, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants