How can I attach a keyboard tray to a desk that is 1/2" thick?
If the desk is particle board (that grainy stuff that is made from sawdust and glue), then I'd avoid trying to screw anything directly into it.

Instead, I would get a piece of 3/8" plywood, and glue it to the bottom of the desk using some construction adhesive (sold in various forms at all the big box stores; PL9000 or No More Nails are some products that would work). You could do some small-ish strips near the areas where the tray will actually attach, but keep in mind that the bigger surface area means more adhesion and spreading of the load. Not seeing what you have, my gut would be something like an 8"x5" piece on each edge of the tray would work. If you don't care you could just do the whole bottom of the desk (on the upside this will also make the desk a bit stronger). Keep it back an inch or two from the edge so you can't really see it.

Screw the plywood to the desk using some 3/4" #8 or #10 wood screws, and if you have them, use some clamps to hold it. You might need to pre-drill (especially for #10) depending on the density of the desk -- if it's too dense, the screw could cause it to crack apart around where you put it in (clamp it first, before predrilling, to make sure everything stays lined up). Be sure the screws are not too long to go through the top, and be careful not to overtighten and strip them out. The screws are just going to hold temporarily while the glue dries, though there's not really any point in taking them out afterwards.

Once dried, you can then use some 3/4" screws (probably even the ones that came with it) to attach the tray. The screws will mostly be holding onto the plywood. 



If the desk is a fairly dense solid wood, you might be able to get away screwing directly into it. Use a shorter, thicker screw (bigger threads = more hold) like a 1/2" #10. It'll probably be necessary to also use a washer to prevent it from going too deep, and you'll definitely want to pre-drill a small hole for each screw.

Alternatively, you can add the plywood as described above, though you might be able to get away with 1/4" thickness.