It's really a complex question, because in X, your window manager will be intercepting many keystrokes. I'm using ICEWM on linux, and CTRL+ALT+RIGHT will cause my virtual desktops to cycle thru. If that is what you are trying to accomplish, look at this pseudocode
use X11::WMCtrl;
foreach my $wrksp (0..9){
$wmctrl->switch($wrksp);