Are 2 players playing simultaneously? Do you want to register only 1 key press (i.e. if player 2 decides to just keep their key held down you don't want the key to repeat and you don't want other keys not being able to be read)
Just to expand on BN2's idea a bit... I would avoid using inkey$() because that has a tendency to lockout other keys and it can be slow. It's good for multiple choice situations but it seems your setting up a "first one to answer the question wins" situation. Using KEYSTATE() has a much better response and can check multiple keypresses without interfering with one another. Anyway, here is an example. Basically, it runs the timer down using the internal TIMER() command. If 5000ms pass (5 secs) it jumps to the buzzer. If player 1 or 2 press their key before the timer runs out, it jumps to their routine. The remarks explain what's going on. Ask if it doesn't make sense:
sync on
sync rate 60
rem let's get the scancodes of the player keys
a=30
l=38
rem start the loop and set the timer
tim=timer()
do
cls
text 0,0,"You've got 5 secs to answer!"
text 0,20,"TIMER: "+str$((timer()-tim)/1000)
rem this uses the internal clock to check if
rem 500ms have passed.
if timer()-tim >=5000
gosub _buzzer
endif
rem now check the keystate of the keys pressed.
rem we want to make them a toggle switch so that they
rem can only register once
oplayer1=player1
player1=keystate(a)
rem if player1 is greate than odl player1 value, that means
rem the a key has been pressed because it is now registering
rem as 1 and oplayer1 is @ 0. If they are equal, then
rem the key is either not pressed at all or is continuing
rem to be held down
if player1 > oplayer1
gosub _player1_response
endif
oplayer2=player2
player2=keystate(l)
rem same detection as player1
if player2 > oplayer2
gosub _player2_response
endif
sync
loop
_buzzer:
text 0,40,"TIMES UP!!!"
wait 1000
tim=timer()
return
_player1_response:
text 0,40,"PLAYER ONE BUZZES IN!"
wait 1000
tim=timer()
return
_player2_response:
text 0,40,"PLAYER TWO BUZZES IN!"
wait 1000
tim=timer()
return
Enjoy your day.