Guide · Milling
How to Machine a Keyway in a Shaft and a Hub
Keyway milling, broaching and shaping: how to hold the shaft, find the centre, reach the width tolerance, measure the depth, and make internal keyways on a CNC machine.
On this page
Size and tolerance
Take the key from the shaft diameter. A 25 mm shaft needs an 8 × 7 key with 4 mm depth in the shaft. The keyway calculator shows all values and checks the strength. The slot width is usually P9 (tight) or N9 (normal). For 8 mm that means: P9 = 7.949 to 7.985 mm and N9 = 7.964 to 8.000 mm.
Keyway in the shaft
- Hold the shaft in V-blocks or in a vise with a V-jaw, and check that it is parallel to X.
- Find the centre with an edge finder on both sides, or with a probe.
- Touch off Z on the highest point of the shaft. The edge of the slot is lower. For a 25 mm shaft and an 8 mm slot the difference is 0.66 mm.
- Rough with a cutter that is one size smaller, for example 7 mm for an 8 mm slot.
- Finish each wall separately. An 8 mm cutter in one pass nearly always makes a slot that is too wide, because it is pushed sideways and has runout.
Keyway in the hub
- Broaching with a push broach and a guide bushing is fast and accurate for through holes.
- Shaping on the lathe: lock the spindle and use a tool in the turret like a slotting machine. Take 0.03 to 0.08 mm per stroke and retract before moving back. This loads the turret and the spindle brake, so ask the machine builder about the limits.
- Wire EDM for hardened parts.
G98
G00 X24.5 Z3.
X25.1
G01 Z-30. F2000.
G00 X24.5
Z3.Measuring
In the shaft measure from the slot bottom to the opposite side: d − t1. In the hub measure from the slot bottom to the opposite bore wall: d + t2. Both are simple with a caliper or an internal gauge and avoid the missing top of the circle.
More guides
- Hard Milling 45 to 62 HRC: Tools, Speeds and Strategy
- Fanuc Macro B for Beginners: Variables, IF, WHILE and Your First Useful Macro
- 3+2 Machining with G68.2, G254 and CYCLE800: Tilted Work Planes Explained
- Faster or Cheaper? How Cutting Speed Changes the Cost per Part
- First Article Inspection and Setup Sheet: A Checklist for Small Shops
- AI in CNC Programming: What Works Today and What to Watch Out For
Frequently asked questions
What is the difference between form A and form B keys?
Form A has round ends and sits in a slot made with an end mill. Form B has square ends and is used in slots made with a disc cutter.
Why is my keyway wider than the cutter?
Runout and deflection. Use a smaller cutter and finish both walls in separate passes.
Was this page helpful?