Is there any way to programatically remap the keys in a Macbook running OSX Mavericks? I want to remap the keys on my keyboard. I want to do it programatically, because I will use some logic to decide what to input. For example, when a user press "A" followed by "S", I will output "λ". In other words, everytime I type a key on my keyboard, I want to intercept it, apply some logic to it and give it back changed before it goes to the focused app.

How?
Have you looked into Keyboard Maestro?  I use it all the time,  I believe you can accomplish with what you want using Keyboard Maestro.

For example:  You can have it check for a typed in string "good" and return morning or afternoon based on the time of day.



With Keyboard Maestro you can execute AppleScript or Shell scripts.  Keyboard Maestro is pretty powerful.   Your macros can then be global or specific to an application.