C-h f this-command-keys:
this-command-keys is a built-in function in `C source code'.
For more information check the manuals.
Return the key sequence that invoked this command.
However, if the command has called read-key-sequence, it returns
the last key sequence that has been read.
The value is a string or a ...
How can i achieve my goal? Should i take another approach?
IIUC the problem arises from a misuse of nconc. The value of unread-command-events is often nil, in which case nconc will not alter it in-place, as there is no cdr to modify. Instead, you should probably be using push or setq to record the value change of unread-command-events.
invocation of ...
self-insert-command is indeed written in C but could just as well be written in Elisp (it's just a result of historical evolution). The variable it uses to figure out which key was pressed is last-command-event.