THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/10/2012 at 03:57, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I'm almost on giving up on CTRL or SHIFT and thought why not use a character key. Problem is I don't know how to check it. The SDK says >BFM_INPUT_CHANNEL
The channel contains the key or button ('A' means A, KEY_F1 means F1)
F1, F2, and so on work without problem, a character not so much. I tried c4d.A, not working, I tried it as a string 'A', and I'm running out of ideas
In the case of a key pressed, the channel returned is an integer value containing the ASCII code of the key.
In Python we can call ord()/unichr() to convert a key code from/to its character. Here's some code:
def KeyboardInput(self, doc, data, bd, win, msg) : channel = msg.GetLong(c4d.BFM_INPUT_CHANNEL) if channel<128: # ascii key code chr = str(unichr(channel)) print chr if chr=='B': return True else: #see KEY_ enum print channel return False
Also, only return True if you really used the event. So if you return False the event is passed along and not blocked.