views:

19

answers:

1

I have a flash conversion function that I call like this:

var key:String=numToChar(keyboardEvent.charCode);

currently the function (see below) supports limited US character set, how to enhance this function as much as possible easily without hardcoding? I want to make the function to support all standard western keycodes (available in US INTERNATIONAL KEYBOARD) such as $€!#%;;!üÜÅÄÖéÉíÍ

The function is:

        private function numToChar(num:int):String {
if (num > 47 && num < 58) {
    var strNums:String = "0123456789";
    return strNums.charAt(num - 48);
} else if (num > 64 && num < 91) {
    var strCaps:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return strCaps.charAt(num - 65);
} else if (num > 96 && num < 123) {
        var strLow:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    //var strLow:String = "abcdefghijklmnopqrstuvwxyz";
    return strLow.charAt(num - 97);
} else {
    return num.toString();
}
A: 

is this good one String.fromCharCode ?

Tom