rohit_jake:
Well, if you'd like, i have given a try at writing a very simple library for this purpose.It will work with 3 x 4 and
4 x 4 keypad.I have uploaded the code to github. This library is also useful if you want to learn how to make libraries like these and how such a library is made.Its made using only the high level functions in arduino, so it is easy to understand.The link is attached below.
It looks like your read_key() is a blocking function; that will limit the use of your library.
2)
You create an instance of a class; why do you pass the instance in your call of give_key()? I'm not a C++ programmer (mostly C) so I don't understand that; it should not be necessary.
3)
Use of goto is hardly ever necessary; definitely not in your example. Most of your code could go in loop().
4)
There are a number of I2C libraries; it would be nice for beginners if you put a link to the correct one in the comments in the example code.
Note:
I hope you're not going to revive all old threads about keypads; this one is about 3.5 years old.