i also use ubuntu. and i also have this problem a lot. what works fairly well for me is double clicking the key that is stuck. useally shift or control. in tekkit opening your inventory and clicking everything into the small crafting slot, then click away the inventory dropping the items on the ground. this also works well for me.
i hope this helps. but im sure that restarting the pc us not the best option.