Hand sanitizer contains alcohol, which can kill gnats on contact. However, it is not the most effective method and can be expensive to use in large quantities. It is better to use a homemade spray made with isopropyl alcohol and water to kill gnats.