starbucks_mafia is spot on. I'm not sure if you misunderstood what he was trying to tell you, but the easiest way to add/remove aliases dynamically is by using the /alias command, like he showed you.
To add a function key:
alias addfkey { alias F1 echo -a I just added this alias by a script! }
alias remfkey { alias F1 }
Type /addfkey and then hit F1.
Then type /remfkey and then hit F1.