when I was changing the admin name and my key board suddenly not working
How were you doing this? You need to follow the correct procedure for this. This may depend on what version of macOS you were using.
Get the Mac to set up an additional administrative account. This will work in all releases of Mac OS X so far.
You need to get into single use mode for steps one and two that are listed below. Start with your computer power off. Hold down command-s. Power on your computer. Continue holding down command-s until you see some text on the screen.
This page will give more details on how to get into single user mode.
http://support.apple.com/kb/HT1492
Type in the following:
The first two commands will depend on your release of Mac OS X. Look at what is typed out in the console to determine the exact format. You do not need to type in the lines beginning with an ampersand, #, they are comments.
# Type the follow two instructions to access the startup disk in read/write.
# Press return after each command.
# in case of partial success repeat this command until errors go away.
/sbin/fsck -fy
/sbin/mount -uw /
# Get setup to activate a new administration account
cd /var/db
pwd
#List all files. The l is a lower case L.
ls -a
# The move command acts as a rename command in this format.
# In Yosemite, this file is zero bytes.
# the disappearance of .AppleSetupDone causes a new administration account
# to be added the next reboot.
mv -i .AppleSetupDone .AppleSetupDone.old
# reboot your mac
shutdown -r now