You can use commands at any time by pressing 'T' then a backslash ('/') followed by a command, but unless cheats have been enabled in SSP or if you are a server OP (Operator) then you cannot use many commands.
(See related link below for a list of commands.)
Chat with our AI personalities
You press T to talk.
With the food held in your hand, press and hold the right mouse button to eat it.
right click on a bed
Press CTRL but you need the mod optifine to do that
You press the space button!