Try the following: 1. In the preamble, \usepackage{textcomp}.
2. Rather than LyX-Code, Insert > Program Listing and paste the code in there. 3. Right click anywhere in the listing, pick Settings..., go the Advanced tab, and insert columns=fullflexible and upquote=true. The former gets rid of kerning and the latter gets you the backtick character. (The vertical quote seems to take care of itself.) /Paul