Skip to content

Commit 2c2799c

Browse files
committed
docs: Update some left over references to Rune() to Str() in docs (fixes #897)
1 parent 8940a91 commit 2c2799c

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

TUTORIAL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ When a non-rune key is pressed, it is available as the `Key` of the event.
3838
```go
3939
switch ev := ev.(type) {
4040
case *tcell.EventKey:
41-
mod, key, ch := ev.Mod(), ev.Key(), ev.Rune()
42-
logMessage(fmt.Sprintf("EventKey Modifiers: %d Key: %d Rune: %d", mod, key, ch))
41+
mod, key, ch := ev.Mod(), ev.Key(), ev.Str()
42+
logMessage(fmt.Sprintf("EventKey Modifiers: %d Key: %d Str: %q", mod, key, ch))
4343
}
4444
```
4545

@@ -304,7 +304,7 @@ func main() {
304304
return
305305
} else if ev.Key() == tcell.KeyCtrlL {
306306
s.Sync()
307-
} else if ev.Rune() == 'C' || ev.Rune() == 'c' {
307+
} else if ev.Str() == "C" || ev.Str() == "c" {
308308
s.Clear()
309309
}
310310
case *tcell.EventMouse:

key.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ import (
3131
// high bit set, or in some cases, by sending an ESC prior to the rune.)
3232
//
3333
// If the value of Key() is KeyRune, then the actual key value will be
34-
// available with the Rune() method. This will be the case for most keys.
34+
// available (as a grapheme cluster) with the Str() method.
35+
// This will be the case for most keys.
36+
//
3537
// In most situations, the modifiers will not be set. For example, if the
3638
// rune is 'A', this will be reported without the ModShift bit set, since
3739
// really can't tell if the Shift key was pressed (it might have been CAPSLOCK,
@@ -66,7 +68,7 @@ func (ev *EventKey) Str() string {
6668
// codes, such as KeyEnter, etc. Most control and function keys are reported
6769
// with unique Key values. Normal alphanumeric and punctuation keys will
6870
// generally return KeyRune here; the specific key can be further decoded
69-
// using the Rune() function.
71+
// using the Str() function.
7072
func (ev *EventKey) Key() Key {
7173
return ev.key
7274
}
@@ -328,7 +330,7 @@ const (
328330
// Key is a generic value for representing keys, and especially special
329331
// keys (function keys, cursor movement keys, etc.) For normal keys, like
330332
// ASCII letters, we use KeyRune, and then expect the application to
331-
// inspect the Rune() member of the EventKey.
333+
// inspect the Str() member of the EventKey.
332334
type Key int16
333335

334336
// This is the list of named keys. KeyRune is special however, in that it is

0 commit comments

Comments
 (0)