The code will work if you have it in a loop. You need to have a main outer game loop.
Your code (as is) positions the sprite once and then has one chance to see if the right key or left key is being pressed; if so it then changes the variables and then ends. And all of this would happen pretty fast so the right key would need to be held pretty much as the program is run.
You need to think of a game as program that only ends if the game is finished or the user exits. This is done by a main game loop. With the game loop set your program will now check for right key and left key input and update the sprites position accordingly, at a rate of 40 frames per second.
sync on
sync rate 40
hide mouse
`set initial coordinates
`player coordinates
shipX = 30
shipY = 50
`display player
`Begin player setup
load image "ship.png",1
sprite 1,shipX,shipY,1
`Main game loop
do
`check for input
if rightkey() = 1 then shipX = shipX - 10
if leftkey() = 1 then shipY = shipY + 10
`display ship each frame
sprite 1,shipX,shipY,1
sync
loop