Smoothly increase a value over time on keypress

So you press for Potion Small 4HP 10 sec and Potion Medium 10HP 15sec and you would get 14HP for 10sec and then 10HP for 5 sec? And not 4HP for 10sec and after those 10sec 10HP for 15sec?