Why can’t I castle? How do I castle?

To castle, you move the king to the desired position – if castling is available, the rook will be moved automatically. Castling is not possible if the king or the rook has moved; or if the king is in check; or if one of the squares the king must travel is controlled by an enemy piece. According to the official FIDE rules, you can castle if the king was in check previously.