[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: keypad

    Is it possible from MCL to distinguish between a digit on the keypad versus
    one above the alphabetic characters...?

You need to look at keycodes, which correspond to the keys themselves
rather than characters. Unfortunately the mapping is not
straightforward and varies between different models of keyboard. Look
at Inside Mac for the data. The following function waits for a keypress
and returns the code; eventrecords also contain keycodes.

(defun get-key ()
  (%stack-block ((p 16) (pp 16))
    (#_GetKeys p)
    (do () (())
      (#_GetKeys pp)
      (dotimes (n 16)
        (unless (= (%get-byte p n) (%get-byte pp n))
          (return-from get-key
            (+ (* n 8)
               (1- (integer-length (logxor (%get-byte p n) (%get-byte pp n)))))))))))