RPI Keyboard key code

Using the standard RPI Keyboard node to detect Keyboard entries.

Using a standard USB keyboard ( usa layout). When pressing:
a : code = 30
b: code= 48
1: code 2
f1: code = 59

Does anyone know the code lookup table?
This does seem to match up with the ACII table.

If you don't mind me asking, how were you able to use the rpi keyboard node, anytime I drop it in my flow it is says "stopped" in red letters under it

It seems to correspond to keyboard layout. So A=30, S = 31, Q=16, W=17, etc. It doesn't correspond to ASCII or USB, so I am a bit puzzled myself.

To get it to start, deploy it with a keyboard attached.

Here is a piece of code I have used to translate. It doesn't do the whole job, but does what I need. If it is lower or upper, the shift key has it use a different translation table. If it is control, it is denoted and is used further down in some other code.

if(msg.payload == 42)  // Caps Shift key
    {
         if (msg.action == "down")
            context.set("Upper",1)
          else
            context.set("Upper",0)
    return null;
    }
if(msg.payload == 29)  // Control key
    {
         if (msg.action == "down")
            context.set("Control",1);
          else
            context.set("Control",0);
    return null;
    }


var translate      = "--1234567890-=  qwertyuiop[]  asdfghjkl;'   zxcvbnm,./"
var translateUcase = '--1234567890_+  QWERTYUIOP{}  ASDFGHJKL:"   ZXCVBNM<>?'
var key_in;
var cumulativeString = context.get("cumulativeString");
if (context.get("Upper")=== 0)
      key_in = translate.substring(msg.payload, msg.payload+1);
    else
      key_in = translateUcase.substring(msg.payload, msg.payload+1);
1 Like