Optifine allows you to enhance your gaming experience and that is why it offers a Hotkey to zoom. Just press and hold it so as to zoom in or out with the Optifine mod.