Two possible solutions come to mind.
#1 - Find a Keyboard Input Script and look at its code
#2 - Fullscreen Scripts
Keyboard should be pretty obvious, but a Fullscreen Script works very similarly by simulating the keypresses of ALT+Enter.
# Alt Enter to go to Fullscreen
showm = Win32API.new 'user32', 'keybd_event', %w(l l l l), ''
showm.call(18,0,0,0) # Hold the Alt Keyboard key
showm.call(13,0,0,0) # Hold the Enter Keyboard key
showm.call(13,0,2,0) # Release the Enter Keyboard key
showm.call(18,0,2,0) # Release the Alt Keyboard key
A bit over my head to explain, and also doesnt detect Input, but simulates it.