Add a new timer called charge timer - for the charge key. You need to step out of the switch and into IF trees.
Code:
.........
var charge_timer =0;
if( key_a)
 charge_time =5;
...sub charge_timer...

if(key_d && key_lastpressed(--key_a--) && charge_time<=0)
----do attack----



As per double keys, it's not complex,
Code:
if(key_a && key_d && key_timer < 0)
{
 .... do -x- .....
}



If you like give each optional key it's own timer... key_a_timer, key_d_timer, ect + key_a_charge timer.....

Also look at this http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=468925#Post468925 , by the Master @txesmi