Different key value on press

I have a dvorak keyboard, and instead of Lua 5.3 I am using Lua 5.43

I notice that the following code does not result in 0, 1, 2 but instead x, b, m. I also notice that 'long pressing' gives curious effects.

function midi_recv( status, data1, data2 )
    local message = { status, data1, data2 }

    if( message_matches( controller.deck['A'].play, message ) ) then
        keypress( XK_0 )
    end
    if( message_matches( controller.deck['A'].cue, message ) ) then
        keypress( XK_1 )
    end
    if( message_matches( controller.deck['A'].sync, message ) ) then
        keypress( XK_2 )
    end

end

I rewrote it to keyup/keydown to be more reliable, but the mapping is still quite odd.