The one that is scanned first. The keyboard controller doesn't see all the keys simultaneously, it scans row for row and checks which intersecting column has made contact (more or less). The letter in the row/column that is scanned first is output first.
i'ts not random, it scans with an order (i don't know the order, it may be different depending on the keyboard), but it always follows an order, like all programs.