Thanks for your advice, Marek, but I'm afraid it doesn't help. When the Macbook is powered up, it just opens to a dialog box showing 'Safe Boot Mode' in red, with a space below for a password. When the correct password is entered, the box vibrates and refuses to accept it.
Following the advice in Apple Old Article 106214, 'Try Disk Utility', I tried to start up from the Installation disc, but when the disc was inserted in the DVD drive, nothing happened. The Safe Boot Mode message was still there, waiting for a password.
Again following 106214 'Use fsck if necessary', I started up in Single User Mode by holding down the Command and S keys at the same time. I got the command screen OK, but when I tried to enter /sbin/fsck -fy as insructed, I could only enter ?SBIN?FSCK -FY. I tried entering other letters in lower case, but could only get upper case.
I can't check if the Macbook Shift key is stuck because I can't type anything anywhere except at the command prompt. I can't access Applications>Utilities>Terminal because I can't get past the Safe Boot Mode dialog box. The Macbook is quite new (bought in March 2011 in the USA), and we have not had any problems with the Shift keys before.
I've seen the same problem discussed on the web, for example at http://www.justanswer.com/mac-computers/4z0ot-mac-osx-just-rebooted-itself-says- safe-boot.html, but the final advice from the expert was to visit a Genius Bar. I live in Portugal, where we have resellers but no Apple Store, so I thought I would try the Apple Support Community first.
(I'm using my own iMac for this message, not the problematic Macbook, of course!)