다음을 통해 공유


Shape.KeyPress 이벤트

도형에 포커스가 있을 때 키를 누르면 발생 합니다.

네임스페이스:  Microsoft.VisualBasic.PowerPacks
어셈블리:  Microsoft.VisualBasic.PowerPacks.Vs(Microsoft.VisualBasic.PowerPacks.Vs.dll)

구문

‘선언
<BrowsableAttribute(True)> _
Public Event KeyPress As KeyPressEventHandler
[BrowsableAttribute(true)]
public event KeyPressEventHandler KeyPress
[BrowsableAttribute(true)]
public:
 event KeyPressEventHandler^ KeyPress {
    void add (KeyPressEventHandler^ value);
    void remove (KeyPressEventHandler^ value);
}
[<BrowsableAttribute(true)>]
member KeyPress : IEvent<KeyPressEventHandler,
    KeyPressEventArgs>
JScript에서는 이벤트를 지원하지 않습니다.

설명

키 이벤트는 다음 순서대로 발생합니다.

KeyDown

KeyPress

KeyUp

비문자 키를 누를 때는 KeyPress 이벤트가 발생하지 않지만 KeyDownKeyUp 이벤트는 발생합니다.

런타임에 키 입력을 샘플링하고 공통 키 입력의 하위 집합을 사용하거나 수정하려면 KeyChar 속성을 사용합니다.

폼 수준 에서만 키보드 이벤트를 처리 하 고 키보드 이벤트를 수신 하는 셰이프를 사용 하려면 설정에서 Handled 속성은 폼의 KeyPress 이벤트 처리 메서드를 true.

이벤트를 처리하는 방법에 대한 자세한 내용은 이벤트 사용을 참조하십시오.

예제

다음 예제에서는 이벤트 처리기에서 KeyPress 이벤트에 응답하는 방법을 보여 줍니다.이 예제에서는 사용자가 있어야는 RectangleShape 폼에 RectangleShape1 이라는 컨트롤입니다.

Private Sub RectangleShape1_KeyPress(
    ByVal sender As Object, 
    ByVal e As System.Windows.Forms.KeyPressEventArgs
  ) Handles RectangleShape1.KeyPress

    Dim ch As Char
    ch = e.KeyChar
    MsgBox("You pressed the " & ch & " key.")
End Sub
private void rectangleShape1_KeyPress(object sender, 
    System.Windows.Forms.KeyPressEventArgs e)
{
    char ch;
    ch = e.KeyChar;
    MessageBox.Show("You pressed the " + ch + " key.");
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

Shape 클래스

Microsoft.VisualBasic.PowerPacks 네임스페이스

기타 리소스

방법: LineShape 컨트롤로 선 그리기(Visual Studio)

방법: OvalShape 및 RectangleShape 컨트롤을 사용하여 도형 그리기(Visual Studio)

Line 및 Shape 컨트롤 소개(Visual Studio)