The figure shows a gear wheel slipped onto a shaft with a shear key. The shaft is supported by a bearing on the left.
 

After the gear is slipped onto the shaft, the key prevents the gear from rotating relative to the shaft.