You can customize the settings, but for me the F9/10/11/12 buttons will do various 'closest to you' targetting. I forget which is which, but one will target the nearest PC, one the nearest NPC, one the nearest enemy, and maybe something else.

Note: It still only targets nearest stuff in the direction you're facing.