Which is why most reputable hotels will ask for a photo ID when running a new key. At least that's the procedure I had to go through when I last forgot my keys in my hotel room and locked myself out.
As for getting a replacement key, yeah, that usually does require some work. In lieu of asking for a replacement you can call the front desk on your cellphone and tell them you're standing outside your room and can't get to your key, and can someone come unlock the door for you.