I know be used to (used not as a tense form) means be accustomed to. I wonder if I can use it (but this time as a passive form of use) to express a purpose. For example,
The keyboard is used to type words.
I also know that as an alternative I can say,
The keyboard is used for typing words.
Is the first sentence grammatically correct or should I avoid it for some reason? Is it perfect English or does it sounds off to native ears?