Opened 6 years ago

Last modified 4 years ago

#1393 new enhancement

Gecko.js, Opera.js must change to use keydown event in isKeyEvent(). Add event onKeyDown, onKeyEvent, change onKeyPress definition

Reported by: guest Owned by: gogo
Priority: normal Milestone: 2.0
Component: Xinha Core Version: trunk
Severity: normal Keywords: event onKeyDown
Cc: adam@…

Description

Can we have an event for onKeyDown please

e.g.
xinha_config.Events.onKeyDown

we currently have onKeyPress - but that fires too late.

Adam J

Change History (3)

comment:1 Changed 5 years ago by gogo

  • Summary changed from event onKeyDown to Gecko.js, Opera.js must change to use keydown event in isKeyEvent(). Add event onKeyDown, onKeyEvent, change onKeyPress definition

See ticket #1274

  • XinhaCore?.js in _editorEvent() sends the onKeyPress event to plugins when isKeyEvent() is true

But the individual browser modules have different ideas on what isKeyEvent() does...

  • InternetExplorer?.js defines isKeyEvent() as a 'keydown'
  • Gecko.js defines isKeyEvent() as a 'keypress'
  • Opera.js defines isKeyEvent() as a 'keypress'
  • WebKit?.js defines isKeyEvent() as a 'keydown'

Changeset:1039 chganged it to keydown for WebKit?.js, InternetExplorer?.js has always used keydown.

The reason is that "special" keys (non printables, meta) apparantly do not trigger a keypress event in those browsers.

I'm not sure what the best resolution to this is.

The onKeyPress event is badly named, it should be onKeyEvent, then we could look at changing both Gecko and Opera to use "keydown" for that, and introduce a new onKeyPress and onKeyDown plugin events (and onKeyUp etc). But this would require...

  1. Changing all the plugins listening to onKeyPress to have them listen to onKeyEvent, I guess some find and replace work isn't that hard
  2. Testing that both Gecko and Opera can work with "keydown" for everything.

Does somebody have time and energy to do that?

comment:2 Changed 5 years ago by gogo

  • Milestone changed from 0.96 to 2.0

comment:3 Changed 4 years ago by adamj

a quick fix is to edit Gecko.js:

change

Xinha.prototype.isKeyEvent = function(event)
{

return event.type == "keypress";

}

to:

Xinha.prototype.isKeyEvent = function(event)
{

return event.type == "keydown";

}

which works fine for me.

Note: See TracTickets for help on using tickets.