Go to Control Panel > Network and Sharing Center > Set up a Connection or Network (in the left pane) > Manually Connect > Next. Now type in the Network Name (SSID), select Security Type and type in the WEP/WPA key.
Sometimes there is more chance of a reliable connection if the key is typed in hexadecimal rather than as ASCII characters. You may also want to tick ‘Start this connection automatically’ and ‘Connect even if the network……‘ > Next. Lastly click ‘Connect to‘ and you should connect to the network.