# `GSFont replaceKey:forMasterIds:leftKey:rightKey:side:writingDirection:`

*Instance Method*

Replaces a kerning key in selected masters and writing direction.

## Declaration

```swift
func replaceKey(_ newKey: String, forMasterIds masterIds: [String], leftKey: String, rightKey: String, side: String, writingDirection: GSWritingDirection)
```

```objc
- (void) replaceKey:(NSString *) newKey forMasterIds:(NSArray<NSString *> *) masterIds leftKey:(NSString *) leftKey rightKey:(NSString *) rightKey side:(NSString *) side writingDirection:(GSWritingDirection) writingDirection;
```

```python
replaceKey_forMasterIds_leftKey_rightKey_side_writingDirection_(newKey: str, masterIds: list[str], leftKey: str, rightKey: str, side: str, writingDirection: GSWritingDirection)
```

## Discussion

`side` uses the kerning-side names used by the Objective-C API.

## See Also

### Kerning Maintenance

- [`GSFont compressKerningForDirection:`](/Core/GlyphsCore/GSFont/compressKerningForDirection:) — Converts redundant glyph kerning to group kerning for a writing direction.
- [`GSFont cleanUpKerningForDirection:`](/Core/GlyphsCore/GSFont/cleanUpKerningForDirection:) — Removes kerning pairs that reference missing glyphs or unused groups.
- [`GSFont sortKerning`](/Core/GlyphsCore/GSFont/sortKerning) — Sorts the kerning dictionaries into font order.
- [`GSFont migrateRTLKerning`](/Core/GlyphsCore/GSFont/migrateRTLKerning) — Moves right-to-left kerning from left-to-right kerning data to right-to-left kerning data.
- [`GSFont migrateRTLKerningDict:doClasses:`](/Core/GlyphsCore/GSFont/migrateRTLKerningDict:doClasses:) — Returns migrated right-to-left kerning data from a kerning dictionary.
- [`GSFont backportRTLKerning`](/Core/GlyphsCore/GSFont/backportRTLKerning) — Returns right-to-left kerning converted back into left-to-right kerning data.
- [`GSFont convertKerning:`](/Core/GlyphsCore/GSFont/convertKerning:) — Converts imported kerning from glyph names to glyph identifiers.

