• Can I do this in the emulator? Highlighting of the key and then selecting using the BTN2 ?

    Yes... Try:

    var KB = [
    'QWERTYUIOP[]',
    'ASDFGHJKL;\'#',
    '\\ZXCVBNM<>/ '];
    var KBX = 3;
    var KBY = 160;
    var KBS = 20; // key spacing
    var KBR = 16; // key size
    var keyx = 0, keyy = 0;
    
    function drawKey(x,y,lit) {
      var px = KBX+x*KBS,
          py = KBY+y*KBS;
      g.setColor(lit?-1:0).fillRect(px, py, px+KBR, py+KBR);
      g.setColor(lit?0:-1).drawString(KB[y][x]­,px+2,py)
      g.setColor(-1);
    }
    
    function drawKB() {
      g.setFont("6x8",2);
      for (var y=0;y<KB.length;y++)
        for (var x=0;x<KB[0].length;x++)
          drawKey(x,y,0);
    }
    
    
    g.clear();
    drawKB();
    drawKey(keyx,keyy,1);
    function moveKey(x,y) {
      drawKey(keyx,keyy,0); // clear old
      keyx += x;  
      if (keyx>=KB[0].length) keyx=0;
      if (keyx<0) keyx=KB[0].length-1;
      keyy += y;
      if (keyy>=KB.length) keyy=0;
      if (keyy<0) keyy=KB.length-1
      drawKey(keyx,keyy,1); // show new
    }
    
    setWatch(_=>moveKey(0,-1),BTN1,{repeat:t­rue});
    setWatch(_=>moveKey(0,1),BTN3,{repeat:tr­ue});
    setWatch(_=>moveKey(-1,0),BTN4,{repeat:t­rue});
    setWatch(_=>moveKey(1,0),BTN5,{repeat:tr­ue});
    setWatch(_=>{
      var key = KB[keyy][keyx];
      console.log(`You pressed "${key}"`);
    },BTN2,{repeat:true});
    
About

Avatar for Gordon @Gordon started