Tree keydown event handling is flaky

Description

Five out of the six ways I know of to make a keydown event handler on a Tree seem to be unreliable, starting in dojo 1.9.1.
This was observed using chrome version "57.0.2987.74 beta (64-bit)" on a macbook pro,
using dojo 1.9.1, 1.9.10, 1.10.1, 1.10.7, 1.11.1, 1.11.3, 1.12.1.
(It seems to work properly in 1.8.13.)

I'll attach a test program that demonstrates, using key handlers connected in various ways.

I didn't bother with anything involving dojo.connect(), since that's deprecated.
And I didn't set tree.onKey*, since that apparently prevents
tree.on(...) and on(tree, ...) from working.
That leaves six other ways to do it (I think):

(A) Tree ctor params.onKey* = function(e){...}

(B) tree.on('key*', function(e){...})

(C) on(tree, 'key*', function(e){...})

(D) on(tree.domNode, 'key*', function(e){...})

(E) tree.domNode.onkey* = function(e){...}

(F) tree.domNode.addEventListener('key*', function(e){...})

Only (A) seems to work reliably. To demonstrate, load the page and do the following:

Click anywhere on the tree to give it keyboard focus

Press-and-quickly-release the 'j' key

A quarter-second later, press-and-quickly-release the space bar.

Console output is as follows. Note the missing handler calls (B)-(F) on the keydown of the Space bar.

Change History (5)

What is up with the initial bug description getting truncated? The same thing happened when I filed #18977. Fortunately I was prepared for something to go wrong this time so I copied and saved the description before I posted it; here it is again:

Five out of the six ways I know of to make a keydown event handler on a Tree seem to be unreliable, starting in dojo 1.9.1.
This was observed using chrome version "57.0.2987.74 beta (64-bit)" on a macbook pro,
using dojo 1.9.1, 1.9.10, 1.10.1, 1.10.7, 1.11.1, 1.11.3, 1.12.1.
(It seems to work properly in 1.8.13.)

I'll attach a test program that demonstrates, using key handlers connected in various ways.

I didn't bother with anything involving dojo.connect(), since that's deprecated.
And I didn't set tree.onKey*, since that apparently prevents
tree.on(...) and on(tree, ...) from working.
That leaves six other ways to do it (I think):

(A) Tree ctor params.onKey* = function(e){...}

(B) tree.on('key*', function(e){...})

(C) on(tree, 'key*', function(e){...})

(D) on(tree.domNode, 'key*', function(e){...})

(E) tree.domNode.onkey* = function(e){...}

(F) tree.domNode.addEventListener('key*', function(e){...})

Only (A) seems to work reliably. To demonstrate, load the page and do the following:

Click anywhere on the tree to give it keyboard focus

Press-and-quickly-release the 'j' key

A quarter-second later, press-and-quickly-release the space bar.

Console output is as follows. Note the missing handler calls (B)-(F) on the keydown of the Space bar.

Refs #16925. IE8 requires preventDefault of keydown SPACE to prevent scrolling but that cancels the subsequent keypress event. Create _keyboardSearch method from _onContainerKeypress that can be called from keydown so that SPACE can be processed there.