If you want to view the security key of a wireless network you've previously been connected to (regardless of whether you're still connected to it), you can try following commands (type into command prompt to execute):
First list all saved profiles
netsh wlan show profiles
Now you can view the details of a wireless network using it's name instead of "ProfileName"
netsh wlan show profile name="ProfileName" key=clear
Note that you may want to execute the commands inside an elevated command prompt (that is, run cmd.exe with administrator privileges) in order to ensure that you have enough rights to view the networks password.
Read more about managing network profiles here.
This works for Windows 8 as well.