Getting keyboard character [SOLVED]

  • On 12/10/2015 at 06:50, xxxxxxxx wrote:

    I want to get the character that the user pressed on the keyboard.

    I am using some code posted here on the forum, but the value is always > 128.
    How to get the character the user pressed?

            channel = bc.GetLong(c4d.BFM_INPUT_CHANNEL)
            print "channel: ", channel
            if channel<128: # ascii key code
                chr = str(unichr(channel))
                print chr
                if chr=='B':
                    return True

  • On 13/10/2015 at 01:47, xxxxxxxx wrote:


    to get the string representation of the character pressed use BFM_INPUT_ASC. You see how it is used in the Liquid Painter tool example.

    Best wishes,

  • On 19/10/2015 at 04:38, xxxxxxxx wrote:

     I can now use it in a commandplugin message:

            dev = bc.GetInt32(c4d.BFM_INPUT_DEVICE)
            if dev == c4d.BFM_INPUT_KEYBOARD:
                print "Keyboard, qual, VALUE: ", bc.GetInt32(c4d.BFM_INPUT_QUALIFIER), bc.GetString(c4d.BFM_INPUT_ASC)
                return True

    but it is not working in the coremessage of a message plugin.
    I am doing this because the message plugin always detects the keyboard and my own plugin only when it is active.
    Is a ">" detected, then a messsage is send from the message plugin to my own pluhin.


  • On 19/10/2015 at 09:25, xxxxxxxx wrote:


    do you mean with "message plugin" a MessageData plugin? Could you post some more complete code? Since the original question is answered you might want to open a new thread.

    Best wishes,

Log in to reply