Multiple button clicks at the same time

I am working on a game idea and I am testing out the button presses. I augmented one of the templates and added this script.


Sub showImageCanvas() 
    canvasItems = [
        { 
            Text:"Hello ImageCanvas"
            TextAttrs:{Color:"#FFCCCCCC", Font:"Medium",
            HAlign:"HCenter", VAlign:"VCenter",
            Direction:"LeftToRight"}
            TargetRect:{x:390,y:357,w:500,h:60}
        }
    ] 
 
   canvas = CreateObject("roImageCanvas")
   port = CreateObject("roMessagePort")
   canvas.SetMessagePort(port)
   'Set opaque background
   canvas.SetLayer(0, {Color:"#FF000000", CompositionMode:"Source"}) 
   canvas.SetRequireAllImagesToDraw(true)
   canvas.SetLayer(1, canvasItems)
   canvas.Show() 
   while(true)
       msg = wait(0,port) 
       if type(msg) = "roImageCanvasEvent" then
           if (msg.isRemoteKeyPressed()) then
               i = msg.GetIndex()
               ' print "Key Pressed - " ; msg.GetIndex()
               ' removing I need up for my game yo!
               ' if (i = 2) then
               if(i = 0 ) then
                   ' Up - Close the screen.
                   canvas.close()
               else if(i=17) then 
                   print "Key Pressed - A"
               else if(i=18) then
                   print "Key pressed - B"
               else if(i=2) then 
                   print "Left"
               else if(i=3) then
                   print "right"
               else if(i=4) then
                   print "down"
               else if(i=5) then
                   print "up"
               else
                   print i;    
               end if
               
           else if (msg.isScreenClosed()) then
               print "Closed"
               return
           end if
       end if
   end while
End Sub

From this I can see when the buttons are pressed, however, if I press 2 at the same time the result is unpredictable. Also it seems that once one key gets the nod (aka is shown in the print window) the other one never gets seen. Is there an onButtonUp call or something to keep track of this sort of thing. Admittedly, I am new to this (just got it for xmas) so I don’t understand threading or any of these concepts quite yet but is there a good example of this?