By definition, security deposits are refundable. Landlords can only retain all or part of the security deposit to:
Common charges include: (1) a reasonable hourly rate for the cleaning or repair work actually performed; (2) carpet cleaning IF it was cleaned immediately prior to your move-in AND your rental agreement says they can charge for this even if you clean the carpet; & (3) loss of the unit while they performed cleaning/repairs in a timely manner.
Here's how you'll win this: 31 days after termination of the tenancy and delivery of possession (this usually means the day you returned the keys), your landlord must give you a written accounting that explains the specific reasons they are withholding money. Anything not accounted for must be returned to you within that same 31-day period. If your landlord fails to make this written accounting, does so too late, or fails to return all or part of your deposit and its in bad faith, then you are entitled to TWICE the amount withheld.
Here are the types of things that you'll want to show the court: