Edit <TV-IP> , <PC-IP> and aa-bb-cc-dd-ee-ff (PC MAC address) with the proper values.
You can edit the key codes as you like .
This script was tested with Samsung 40ES5500 model and en-us keyboard layout.
Many thanks to Asif Iqbal .