external keyboard to generate note-on note-off via hi object

    Jul 27 2010 | 2:05 am
    I'm using max msp to turn an external usb keyboard into a midi controller. The hi object gives me numbers corresponding to each key pressed down starting with device number 12. When more than one key is pressed the number corresponding to the next key shows up under device number 13, the next key will be under 14, etc... I can use the select object to generate bangs and use the note out object to trigger midi notes from each key. However, when I release a key, the key number in the largest device number jumps back to zero and the key numbers slide down to the next lowest device number.
    For example if I held down "a" then "s" then released "a" then "s" I would see 4 (the key number for a) in device 12, and 0 in device 13, then 4 in device 12 and 22 (the key number for s) in device 13. When "a" is released, device 12 would show key number 22 and device 13 would show 0. So the 22 would slide down from device 13 to 12 instead of device 12 switching from 4 to 0 and device 13 remaining unchanged.
    I can't figure out how to determine when each key is released to generate note off's. Does anyone have any idea for some logic that might accomplish this?
    If my situation is still unclear I'll try to elaborate