To lock the keys automatically, select Menu > settings > Security > Keyguard > Automatic keyguard and select On.
To unlock the keys, select Unlock and press *.