Reputation: 1036
Using Python, I'm reading lines from a Logfile produced by a Firefox extension. One of the inputs in the log is a number that represents the value returned by Event.keycode() that has been used on a keyup event.
While reading the loglines, I want to convert those keycode values to the char they're representing.
Example logfile line:
1338899783924,keyup,[object HTMLInputElement],true,true,false,undefined,undefined,undefined,undefined,16,undefined,false,undefined,undefined,undefined,false
In this case the 16 is the value returned by Event.keycode
Solved this problem already in Java using a scriptengine and converting the value with javascript. Maybe that could be used for python, too?
Note: Python only, the data is already gathered and there is no changing the extension or w/e
Upvotes: 1
Views: 1259
Reputation:
What about this, assuming the keycode is a Unicode code point ?
chr(int(line.split(",")[10]))
See also python doc for chr
Upvotes: 2