Ignore:
Timestamp:
02/10/18 06:36:44 (2 years ago)
Author:
gogo
Message:

Rewrite and standardise key events (see #1393), add onKeyDown, onKeyUp and also onShortCut

This commit rewrites much of the keyboard event handling, but it is (hopefully, in theory, as far as I can test) backwards compatible, in fact, it's so compatible it is used in the exact same way so far as plugins are concerned.

It adds events for plugins of onKeyDown, onKeyUp and also onShortCut

The existing onKeyPress is still fired - however with some caveat, namely the intention is that onKeyPress is only fired for the following classifications of key pressing...

"Adding Characters"

letters, numbers, space, punctuation, symbols, tab, enter

"Deleting Characters"

delete, backspace

"Shortcuts and Other Useful Things"

esc, ctrl-a, ctrl-b...


where previously under some browsers (WebKit?, IE) it would be fired for all keydown events, now it will only fire for "normally useful" events, and the event noise is reduced.

Also considerable work to make sure that the browsers are consistent, to ensure this some "keydown" events in some browsers also produce a "fake" keypress event, where in other browsers they would get a real keypress event (and we want them to).

getKey() hs been improved in Gecko and WebKit? and should be about the same for most uses (certainly all uses in the Xinha distribution), as it now uses the DOM3 keyboard event codes, special keys are now returned by name (where possible), eg tab is reported by getKey as "Tab", where previously, it would have been probably an actual tab character (but other special keys would have been pretty random incorrect characters).

Whew. This was a lot more work than I had anticipated. KeyboardEvent? across browsers is a mess.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/InsertNote/InsertNote.js

    r1086 r1394  
    568568  // This seems a bit hacky, but I don't presently see 
    569569  // a better way. 
     570  //@NOTE: 8 = Backspace, 46 = Delete; this undocumented 
     571  //  function apears to be for handling delete note references 
     572  //  to have the note automatically deleted also 
    570573  if (event.keyCode == 8 || event.keyCode == 46) 
    571574  { 
Note: See TracChangeset for help on using the changeset viewer.