jetzt icon indicating copy to clipboard operation
jetzt copied to clipboard

Current key handling disturbes mobile usage

Open peteruithoven opened this issue 11 years ago • 6 comments
trafficstars

I want to improve Jetzt for use on mobile devices. One of the first frustrating things is that is somehow seemed to zoom in and open the keyboard (Using Chrome on Android). Looking through the code this is caused by manually setting focus on the hiddenInput field. (hiddenInput.focus();) Why do we do this? My guess is that we do this to override all default actions behind keys, like pressing down scrolls the page down. But I found that using return false in the keyDown handler prevents this as well. Does someone care to comment?

peteruithoven avatar Mar 24 '14 00:03 peteruithoven

The hidden input thing was done to address this issue: #18

I just did some googling and found out you can capture keydowns with a div if you set tabindex=0. That probably won't bring up the keyboard.

ds300 avatar Mar 24 '14 01:03 ds300

I understand. Maybe I'll set up a test site which uses keys (because the mentioned website is down) and experiment further. Setting the tabindex to 0 doesn't seem to prevent the keyboard popup (see below how I tried). Maybe I'll try setting focus to the reader itself instead of a input element, because it makes sense for mobile operating systems open the keyboard and zoom in on them.

hiddenInput.setAttribute("tabIndex",0);
hiddenInput.tabIndex = 0;

peteruithoven avatar Mar 24 '14 10:03 peteruithoven

try changing hidenInput to a div first ;)

ds300 avatar Mar 24 '14 13:03 ds300

In a quick test that seemed to highlight the left wrapper... Not sure why. But when we can set the focus to the reader itself there is no need for a hidden element, which seems better, less hacky.

peteruithoven avatar Mar 24 '14 13:03 peteruithoven

Setting the focus to a div hiddenInput or the reader as a whole solves the problem in Chrome on Android. It also still steals the focus of a website like t3n.de.

Should I do a PR on dev, even though you guys are rewriting it into coffeescript or should I do a PR on coffee?

peteruithoven avatar Mar 26 '14 10:03 peteruithoven

Just merge it straight into dev. :+1: I'm going to do the js2coffee thing today.

ds300 avatar Mar 26 '14 13:03 ds300