[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: keypad
- To: lynch@ils.nwu.edu
- Subject: Re: keypad
- From: Michael Travers <mt@media.mit.edu>
- Date: Wed, 05 Jan 94 16:48:57 -0500
- Cc: info-mcl@cambridge.apple.com
- In-reply-to: Your message of "Wed, 05 Jan 94 14:34:36 CST." <9401052034.AA02365@aristotle.ils.nwu.edu>
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)))))))))))