@staticmethod
def ctrl(char):
    """
        Calculate the control code for a given key.  For example, this converts
        "a" to 1 (which is the code for ctrl-a).

        :param char: The key to convert to a control code.
        :return: The control code as an integer or None if unknown.
        """
    if not isinstance(char, int):
        char = ord(char.upper())
    return char & 31 if 64 <= char <= 95 else None
