devilry/devilry-django — Issue #278: Handle OSX CMD modifier key-events
Author: espenak
Created: 2012-03-06 08:48:39+00:00
State: open

Extjs supports CMD for selection, but not as a modifier key for ``Ext.util.KeyMap``. This makes it hard to handle ``CMD-a``. As you can read here: http://stackoverflow.com/questions/3902635/how-does-one-capture-a-macs-command-key-via-javascript, we may use browser specific solutions, however it is har to hack this into KeyMap because it requires that we listen for a keypress event and then assume that the user press the _other_ key within some timeframe.

E.g: When a user is trying to press ``CMD-a``, we would:
- First catch the CMD ``keydown`` event as a browser specific ``event.keyCode``.
- Then wait for the user to press the ``a``-key, or the user releases the CMD key.

This is not to hard to do, however it does require a custom subclass of ``Ext.util.KeyMap``. We can easily add ``keyup`` events in the public ``enable`` and ``disable`` methods. However, the methods that handles events, ``handleKeyDown``, ``processBinding`` and ``checkModifiers``, are all private methods.

A mostly safe solution would be to:
- extend ``checkModifiers`` to handle ``CMD`` as ``CTRL``.
- extend ``enable`` and ``disable`` with a custom keyup and keydown handler.
- extend the ``constructor`` to no allow a custom ``eventName``.