Is your technical request related to a problem? Please describe.
maxGraph identifies keyboard keys with KeyboardEvent.keyCode, which is deprecated. Its values depend on the browser, the platform and the keyboard layout: the Command key on macOS is reported as 224 by Firefox and 91/93 by the other browsers, and 93 is the ContextMenu key on Windows. Browsers keep supporting it for compatibility, but new code is expected to use KeyboardEvent.key (the logical key) or KeyboardEvent.code (the physical key).
The numeric codes are part of the public API, not only of the internals:
KeyHandler stores its bindings in normalKeys, shiftKeys, controlKeys and controlShiftKeys, indexed by keyCode, and bindKey, bindShiftKey, bindControlKey and bindControlShiftKey take a code: number.
EditorKeyHandler.bindAction takes the same number, and EditorKeyHandlerCodec reads it from the as attribute of the XML configuration (<add as="88" control="true" action="cut"/>).
CellEditorHandler compares evt.keyCode to detect Escape, Enter, F2, Backspace and Delete.
The named constants of KeyCodes (added in 0.26.0) make the current code readable, but they still carry keyCode values.
Describe the solution you'd like
Provide a new key handler that identifies keys with KeyboardEvent.key (or code where the physical position matters, such as the arrow keys), next to the existing KeyHandler, and deprecate KeyHandler. Do the same for the editor part: a new counterpart of EditorKeyHandler, with its own codec and XML configuration format based on key names, and deprecate EditorKeyHandler and EditorKeyHandlerCodec.
Users keep their current code working and migrate at their own pace, and the deprecated classes are removed in a later major version. KeyCodes would be deprecated along with them, or complemented by an equivalent holding key values for the new handlers.
The internal checks that do not belong to the binding API, such as those of CellEditorHandler, can move to key directly.
Describe alternatives you've considered
- Keep
keyCode: it still works in all supported browsers, at the price of the browser-specific values above and of relying on a deprecated property.
- Change
KeyHandler and EditorKeyHandler in place, accepting both a keyCode number and a key string during a transition period: the binding maps, the signatures and the XML format would all change, which is too large a breaking change for existing users.
- Switch the internals only, and translate the numeric bindings internally: no breaking change, but the public API keeps exposing the deprecated notion.
Additional context
Some JSDoc examples of CellEditorHandler compare keyCode ranges (digits 48 to 57, numpad digits 96 to 105) and use evt.which, which is deprecated as well. They would need updating along with the code.