The way it works with mouse and keyboard is just that it's a toggle. It'll lock onto whatever enemy is nearest to your cursor.