Minecraft wiki entry for Inventory, associated text: Pressing 1–9 switches the item hovered over with the cursor with the item in that slot of the hotbar, or moves the item from one to the other if either slot is empty. However pressing F does a similar thing but only affects the off-hand slot.