You can do:
Code:
#showtooltip
/dismount
/cast [nomounted] Levitate
(remove the
[nomounted] if you want to see the error message from Levitate)
It won't work in
one key-press if you are mounted because it takes time for you to dismount - the /dismount command doesn't trigger the GCD, but it takes at least the server round-trip time to actually perform the dismount (if you are mounted), plus any additional delay the server introduces. If you aren't mounted, then /dismount does nothing.
That macro is what I use anyway (wrote it after riding off the Aldor tower while using the wrong mount, and not being able to lev because I was mounted, d'oh!)
Oh, you might also want to change this to something like the following when you get a flying mount:
Code:
#showtooltip
/stopmacro [flying]
/dismount
/cast [nomounted] Levitate
To stop you dismounting and casting Levitate if you are already flying!