An extension to http://codereview.appspot.com/2067042/
This adds cross-browser keyboard shortcuts through 'keydown' handlers instead of 'keypress' handlers.
This allows to handle special keys like "Esc", "CtrlS" etc. on Chrome, and enables shortcuts even when alternative keyboard layout is active.
Test installation is at http://codereview-keydown.appspot.com/
Without going into a detailed review of your change, you end up with stuff like ...
15 years, 9 months ago
(2010-08-31 17:33:02 UTC)
#2
Without going into a detailed review of your change, you end up with stuff like
'Shift3' /* '#' */
Now, on a German layout (as well as azerty, etc) the numbers are
actually shift'd while the the !@#$% etc characters are accessed
without shift (and _highly frustratingly_ also moved over 1, so when
typing on them as though they were qwerty, looking at what's written
on the keys is doubly wrong, but I digress).
How is that handled? Even if I have a "native" German layout keyboard,
will Shift3 still mean '#'? Or will it mean some other key? What about
all the other keys? For example I remember that on an azerty keyboard
the m key is where the ; key is (and all the ,./' keys are jumbled
around). Will I be able to press the 'm' key, or will I have to
remember where m is on a qwerty keyboard and press that instead? [I
honestly have no idea, btw, but I think this needs to be understood
before such a change is made.]
-ilia
PS, it appears that building indices on GAE takes an excruciatingly
long time, so if it's the first time you're uploading the rietveld
app, prepare to wait 12h before it functions.
On Tue, Aug 31, 2010 at 1:21 PM, <techtonik@gmail.com> wrote:
> Reviewers: GvR, Ilia Mirkin,
>
> Message:
> Here is the full keydown handler.
>
> Description:
> An extension to http://codereview.appspot.com/2067042/
>
> This adds cross-browser keyboard shortcuts through 'keydown' handlers
> instead of 'keypress' handlers.
>
> This allows to handle special keys like "Esc", "CtrlS" etc. on Chrome,
> and enables shortcuts even when alternative keyboard layout is active.
>
> P.S. I've uploaded the app to http://codereview-keydown.appspot.com/ but
> it shows 500 error, it works ok locally.
>
> Please review this at http://codereview.appspot.com/2055042/
>
> Affected files:
> M static/script.js
> M templates/all.html
> M templates/diff.html
> M templates/diff2.html
> M templates/issue.html
> M templates/patch.html
> M templates/starred.html
> M templates/user.html
>
>
>
--
Ilia Mirkin
imirkin@alum.mit.edu
On 2010/08/31 17:33:02, imirkin_alum.mit.edu wrote: > Without going into a detailed review of your change, ...
15 years, 9 months ago
(2010-09-01 07:12:27 UTC)
#3
On 2010/08/31 17:33:02, imirkin_alum.mit.edu wrote:
> Without going into a detailed review of your change, you end up with stuff
like
>
> 'Shift3' /* '#' */
>
> Now, on a German layout (as well as azerty, etc) the numbers are
> actually shift'd while the the !@#$% etc characters are accessed
> without shift (and _highly frustratingly_ also moved over 1, so when
> typing on them as though they were qwerty, looking at what's written
> on the keys is doubly wrong, but I digress).
When you switch layout, the original English keys work, and that's how it should
be. You've probably seen Vim tutorial, which tells not to memorize symbol names.
Because shortcuts are not learned symbolically - they stay as memorized
reflexes. Changing position of shortcuts every time you change layout will drive
you crazy. I doubt that you want to memorize Shift/ for '?' key in English
layout and Shift7 for the same '?' in Russian?
> How is that handled? Even if I have a "native" German layout keyboard,
> will Shift3 still mean '#'? Or will it mean some other key? What about
> all the other keys?
Every key on the keyboard has its own number (scan code). Shift-3 will mean the
key that is treated as key 3 by modern browsers (i.e. that has the same scan
code), pressed together with Shift. As we use standard English layout when
designing our shortcuts, this will correspond to symbol '#'. If you afraid that
the actual symbol value for this key will be different for non-standard
keyboards and users won't find it - use 'Shift-3' - it will work 100%
> For example I remember that on an azerty keyboard
> the m key is where the ; key is (and all the ,./' keys are jumbled
> around). Will I be able to press the 'm' key, or will I have to
> remember where m is on a qwerty keyboard and press that instead? [I
> honestly have no idea, btw, but I think this needs to be understood
> before such a change is made.]
As I don't have azerty keyboard, so can only assume that such details were taken
care by browsers/os, and propose to test how it works on
http://codereview-keydown.appspot.com/
> PS, it appears that building indices on GAE takes an excruciatingly
> long time, so if it's the first time you're uploading the rietveld
> app, prepare to wait 12h before it functions.
Finally it works. I've also had a missing brace in script.js that surprisingly
didn't prevent application to run on my local machine, but gave errors when
uploaded.
On Wed, Sep 1, 2010 at 00:12, <techtonik@gmail.com> wrote: > On 2010/08/31 17:33:02, imirkin_alum.mit.edu wrote: ...
15 years, 9 months ago
(2010-09-01 14:25:21 UTC)
#4
On Wed, Sep 1, 2010 at 00:12, <techtonik@gmail.com> wrote:
> On 2010/08/31 17:33:02, imirkin_alum.mit.edu wrote:
>> PS, it appears that building indices on GAE takes an excruciatingly
>> long time, so if it's the first time you're uploading the rietveld
>> app, prepare to wait 12h before it functions.
>
> Finally it works. I've also had a missing brace in script.js that
> surprisingly didn't prevent application to run on my local machine, but
> gave errors when uploaded.
As an aside, there were some production issues recently that caused
index building to be slower than usual. These should now (or will
soon) be fixed and index building will be fast again.
--
--Guido van Rossum (python.org/~guido)
This seems to work (using a standard US keyboard), and I think I understand what ...
15 years, 9 months ago
(2010-09-01 14:36:44 UTC)
#5
This seems to work (using a standard US keyboard), and I think I understand what
it does, but your test instance doesn't seem to handle ESC correctly (with
either Chrome 5 or Firefox 3.6.8 on Mac OS X). It should cancel editing a draft
comment but doesn't. (Maybe that's something you can copy from Ilia's patch ?)
http://codereview.appspot.com/2055042/diff/12001/13001
File app.yaml (right):
http://codereview.appspot.com/2055042/diff/12001/13001#newcode1
app.yaml:1: application: codereview-keydown
You shouldn't put files like this in the code review.
As mentioned in techtonik's previous reply, I want to know the preferred way for a ...
15 years, 9 months ago
(2010-09-01 20:05:19 UTC)
#6
As mentioned in techtonik's previous reply, I want to know the preferred way for
a user to memorize a shortcut key. By its symbol or position?
These two different ways may require totally different solutions.
If users are used to memorize shortcut keys by their symbols, then using
keypress events would be the best solution for us. Because on different keyboard
layouts, same character may correspond to different keycodes and/or key
bindings. There is no reliable way to get correct character from a keycode
without knowing details of the keyboard layout. For example, on French keyboard,
'#' character corresponds to AltGR+3 rather than Shift+3. And even worse,
different systems/browsers may generate different keycodes for the same key. So
keypress event is the only reliable way to identify the real character(symbol)
of a key event.
If users are used to memorize shortcut keys by their positions, then
unfortunately, there is no way for us to support it. Because a keycode does not
correspond to the position of a key at all. A key on the same position may
generate different keycodes on different keyboard layouts.
Conclusion: IMHO, we can only support symbolic shortcut keys by using keypress
events as much as possible.
When using a keyboard with German layout it works too. ESC works as expected (Chromium ...
15 years, 9 months ago
(2010-09-01 20:09:10 UTC)
#7
When using a keyboard with German layout it works too. ESC works as
expected (Chromium Development Snapshot on Linux), "?" is smart as
always :)
One minor nit is that the document doesn't seem to get the focus back
when hitting ESC to close the dialog or the help popup. This works for
example with Opera and Firefox on codereview and codereview-keydown.
Anatoly, do I understand this correctly, that one of your use cases is
when people are switching keyboad layout but want to use the same
(physical) keys? - Nevermind if I'm completely wrong... Just say "No" and
I won't bring it up again :)
BTW, I didn't realized that ESC stopped working on
codereview.appspot.com at some point. I'm pretty sure that it worked
with older versions of Chromium or script.js.
Andi
guido@google.com writes:
> This seems to work (using a standard US keyboard), and I think I
> understand what it does, but your test instance doesn't seem to handle
> ESC correctly (with either Chrome 5 or Firefox 3.6.8 on Mac OS X). It
> should cancel editing a draft comment but doesn't. (Maybe that's
> something you can copy from Ilia's patch ?)
>
>
> http://codereview.appspot.com/2055042/diff/12001/13001
> File app.yaml (right):
>
> http://codereview.appspot.com/2055042/diff/12001/13001#newcode1
> app.yaml:1: application: codereview-keydown
> You shouldn't put files like this in the code review.
>
> http://codereview.appspot.com/2055042/
>
> --
> You received this message because you are subscribed to the Google Groups
"codereview-discuss" group.
> To post to this group, send email to codereview-discuss@googlegroups.com.
> To unsubscribe from this group, send email to
codereview-discuss+unsubscribe@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/codereview-discuss?hl=en.
On 2010/09/01 14:36:44, guido wrote: > This seems to work (using a standard US keyboard), ...
15 years, 9 months ago
(2010-09-06 20:24:26 UTC)
#9
On 2010/09/01 14:36:44, guido wrote:
> This seems to work (using a standard US keyboard), and I think I understand
what
> it does, but your test instance doesn't seem to handle ESC correctly (with
> either Chrome 5 or Firefox 3.6.8 on Mac OS X). It should cancel editing a
draft
> comment but doesn't. (Maybe that's something you can copy from Ilia's patch ?)
I hope we talk about draft message, not about inline comments? I can't see what
can be copied from Ilia's patch, except e.preventDefault(); in M_stopBubble, but
that's seems illogical. Unfortunately, I don't have access to MacOS box to test,
but can you confirm that Esc works on your Linux box to remove draft message
dialog box?
> http://codereview.appspot.com/2055042/diff/12001/13001#newcode1
> app.yaml:1: application: codereview-keydown
> You shouldn't put files like this in the code review.
Is there a way to filter them out for upload.py without reverting in SVN?
On Mon, Sep 6, 2010 at 4:24 PM, <techtonik@gmail.com> wrote: > I hope we talk ...
15 years, 9 months ago
(2010-09-06 20:43:40 UTC)
#10
On Mon, Sep 6, 2010 at 4:24 PM, <techtonik@gmail.com> wrote:
> I hope we talk about draft message, not about inline comments? I can't
> see what can be copied from Ilia's patch, except e.preventDefault(); in
> M_stopBubble, but that's seems illogical. Unfortunately, I don't have
> access to MacOS box to test, but can you confirm that Esc works on your
> Linux box to remove draft message dialog box?
Talking about inline comments. The check in esc is buggy -- it will
always try to esc the draft message. It needs to check whether the
draft message is visible first.
On 2010/09/01 20:05:19, james.su wrote: > As mentioned in techtonik's previous reply, I want to ...
15 years, 9 months ago
(2010-09-06 20:44:33 UTC)
#11
On 2010/09/01 20:05:19, james.su wrote:
> As mentioned in techtonik's previous reply, I want to know the preferred way
for
> a user to memorize a shortcut key. By its symbol or position?
By its key code. Browser guarantees to generate key codes consistently no matter
in which corner of the keyboard your "Esc" key is located. Same is true for
other keys on standard US keyboard. If browser fails to provide correct key code
then there is nothing you can do to help its users use web application
shortcuts. Chances are that with non-US keyboards they have non-US letters, so
keypress is not a solution either.
> And even worse,
> different systems/browsers may generate different keycodes for the same key.
These are exceptions that are well-described - you will be able to code
cross-platform behavior based only on browser differences (although it seems
there are issues with MacOS currently).
> So
> keypress event is the only reliable way to identify the real character(symbol)
> of a key event.
If this key event has character symbol, which is not true for keys like Esc. I
wouldn't say that keypress event is reliable either, because with switched
keyboard layout for different language you will miss the key event.
> If users are used to memorize shortcut keys by their positions, then
> unfortunately, there is no way for us to support it. Because a keycode does
not
> correspond to the position of a key at all. A key on the same position may
> generate different keycodes on different keyboard layouts.
Key 'A' is key 'A' with key code of key 'A', no matter where it is located.
Users don't memorize position - they memorize key 'A' in US/English layout. I do
not know about dvorak keyboards - this needs to be tested - but my opinion is
that browser will return the same key code for letter 'A' on dvorak keyboard as
it returns for 'A' on qwerty.
On Mon, Sep 6, 2010 at 4:44 PM, <techtonik@gmail.com> wrote: > Key 'A' is key ...
15 years, 9 months ago
(2010-09-06 20:52:39 UTC)
#12
On Mon, Sep 6, 2010 at 4:44 PM, <techtonik@gmail.com> wrote:
> Key 'A' is key 'A' with key code of key 'A', no matter where it is
> located. Users don't memorize position - they memorize key 'A' in
> US/English layout. I do not know about dvorak keyboards - this needs to
> be tested - but my opinion is that browser will return the same key code
> for letter 'A' on dvorak keyboard as it returns for 'A' on qwerty.
http://en.wikipedia.org/wiki/AZERTY (zoomed in:
http://en.wikipedia.org/wiki/File:Belgian_pc_keyboard.svg)
So when someone presses the key that has the ", 3, and # letters on
it, you think that the keycode will be '3', despite it being in the
"shift" version of the key? I guess that feels inconsistent to me, but
it could be true. Same for the ? key -- on a US keyboard it's
"shift-/", but on AZERTY it's "shift-,".
Our opinions of how it works don't really matter, of course... it's a
question of what really happens :)
-ilia
On 2010/09/01 20:09:10, Andi Albrecht wrote: > One minor nit is that the document doesn't ...
15 years, 9 months ago
(2010-09-07 08:31:15 UTC)
#13
On 2010/09/01 20:09:10, Andi Albrecht wrote:
> One minor nit is that the document doesn't seem to get the focus back
> when hitting ESC to close the dialog or the help popup. This works for
> example with Opera and Firefox on codereview and codereview-keydown.
Fixed for draft message dialog in 7th changeset and refreshed
http://codereview-keydown.appspot.com/
> Anatoly, do I understand this correctly, that one of your use cases is
> when people are switching keyboad layout but want to use the same
> (physical) keys? - Nevermind if I'm completely wrong... Just say "No" and
> I won't bring it up again :)
You're absolutely correct. That's the primary use case for this solution.
> BTW, I didn't realized that ESC stopped working on
> http://codereview.appspot.com at some point. I'm pretty sure that it worked
> with older versions of Chromium or script.js.
It may be that Rietveld entered or left quirks mode at some point.
On 2010/09/06 20:43:40, imirkin_alum.mit.edu wrote: > Talking about inline comments. The check in esc is ...
15 years, 9 months ago
(2010-09-07 08:54:19 UTC)
#14
On 2010/09/06 20:43:40, imirkin_alum.mit.edu wrote:
> Talking about inline comments. The check in esc is buggy -- it will
> always try to esc the draft message. It needs to check whether the
> draft message is visible first.
Cancelling inline comments with an Esc never worked. I can be contributed as a
separate patch later to keep this issue focused on core part of 'keydown'
processing. I've created a ticket to track this at
http://code.google.com/p/rietveld/issues/detail?id=225
On 2010/09/06 20:52:39, imirkin_alum.mit.edu wrote: > http://en.wikipedia.org/wiki/AZERTY (zoomed in: > http://en.wikipedia.org/wiki/File:Belgian_pc_keyboard.svg) > > So when ...
15 years, 9 months ago
(2010-09-07 09:28:30 UTC)
#15
On 2010/09/06 20:52:39, imirkin_alum.mit.edu wrote:
> http://en.wikipedia.org/wiki/AZERTY (zoomed in:
> http://en.wikipedia.org/wiki/File:Belgian_pc_keyboard.svg)
>
> So when someone presses the key that has the ", 3, and # letters on
> it, you think that the keycode will be '3', despite it being in the
> "shift" version of the key?
Exactly.
> I guess that feels inconsistent to me, but
> it could be true. Same for the ? key -- on a US keyboard it's
> "shift-/", but on AZERTY it's "shift-,".
> Our opinions of how it works don't really matter, of course... it's a
> question of what really happens :)
That's right. If anybody has an AZERTY keyboard, it is easy to test what keycode
browser returns on http://unixpapa.com/js/testkey.html Reference key on US
keyboard is [/?] with a keycode of 191.
For "/":
keydown keyCode=191 which=191 charCode=0
keyIdentifier=U+00BF keyLocation=0
shiftKey=false ctrlKey=false altKey=false metaKey=false
keypress keyCode=47 (/) which=47 (/) charCode=47 (/)
shiftKey=false ctrlKey=false altKey=false metaKey=false
For "?":
keydown keyCode=191 which=191 charCode=0
keyIdentifier=U+00BF keyLocation=0
shiftKey=true ctrlKey=false altKey=false metaKey=false
keypress keyCode=63 (?) which=63 (?) charCode=63 (?)
shiftKey=true ctrlKey=false altKey=false metaKey=false
This is Chrome 6.0.472.53
Russian layout without Shift:
keydown keyCode=191 which=191 charCode=0
keyIdentifier=U+00BF keyLocation=0
shiftKey=false ctrlKey=false altKey=false metaKey=false
keypress keyCode=46 (.) which=46 (.) charCode=46 (.)
shiftKey=false ctrlKey=false altKey=false metaKey=false
With shift:
keydown keyCode=191 which=191 charCode=0
keyIdentifier=U+00BF keyLocation=0
shiftKey=true ctrlKey=false altKey=false metaKey=false
keypress keyCode=44 (,) which=44 (,) charCode=44 (,)
shiftKey=true ctrlKey=false altKey=false metaKey=false
All done and ready for review at http://codereview-keydown.appspot.com/ The last changes (patchsets 9 and 10) ...
15 years, 9 months ago
(2010-09-08 19:30:37 UTC)
#17
All done and ready for review at http://codereview-keydown.appspot.com/
The last changes (patchsets 9 and 10) include proper fix for 'Esc' handling
inside draft and comment textareas, and also add dash in shortcut key names to
make them more readable.
Please remind if I've missed something else.
It is completely independent in the terms code, so can be applied to current trunk. ...
15 years, 9 months ago
(2010-09-13 10:09:53 UTC)
#22
It is completely independent in the terms code, so can be applied to current
trunk. I meant that without Ilia's work on this issue I wouldn't come up with
this solution.
techtonik@gmail.com writes: > It is completely independent in the terms code, so can be applied ...
15 years, 9 months ago
(2010-09-13 10:24:27 UTC)
#23
techtonik@gmail.com writes:
> It is completely independent in the terms code, so can be applied to
> current trunk. I meant that without Ilia's work on this issue I wouldn't
> come up with this solution.
Thanks for the feedback and the patch!
Committed r572 and live.
Andi
>
>
> http://codereview.appspot.com/2055042/
Yes. I couldn't find a key on my keyboard that corresponds to this Meta key ...
15 years, 9 months ago
(2010-09-18 14:15:08 UTC)
#26
Yes. I couldn't find a key on my keyboard that corresponds to this Meta key in
Windows, so I couldn't get its code. But there is a fix at
http://codereview.appspot.com/2200044/ that should help to stop 'm' processing
when Meta-m (or Cmd-m) is pressed on MacOS.
Issue 2055042: Cross-browser shortcut handling through keydown handlers (fixes Esc/CtrlS handling on Chrome)
(Closed)
Created 15 years, 9 months ago by techtonik
Modified 15 years, 9 months ago
Reviewers: GvR, Ilia Mirkin, imirkin_alum.mit.edu, guido, james.su, Andi Albrecht
Base URL: http://rietveld.googlecode.com/svn/trunk/
Comments: 15