键盘各键对应的ASCII码值(包括鼠标和键盘所有的键)

键盘各键对应的ASCII码值(包括鼠标和键盘所有的键),第1张

键盘和鼠标各个键位对应的ASCII码值如下:

这就是键盘和鼠标上各个键位对应的ASCII码,一些支持宏编程的键盘和鼠标上面的一些键位没有专属的ASCII码,具体对应的ASCII码要看编程对应的对象。

扩展资料:

32~126(共95个)是字符(32是空格),其中48~57为0到9十个阿拉伯数字。

65~90为26个大写英文字母,97~122号为26个小写英文字母,其余为一些标点符号、运算符号等。

同时还要注意,在标准ASCII中,其最高位(b7)用作奇偶校验位。所谓奇偶校验,是指在代码传送过程中用来检验是否出现错误的一种方法,一般分奇校验和偶校验两种。奇校验规定:正确的代码一个字节中1的个数必须是奇数,若非奇数,则在最高位b7添0;偶校验规定:正确的代码一个字节中1的个数必须是偶数,若非偶数,则在最高位b7添1。

后128个称为扩展ASCII码。许多基于x86的系统都支持使用扩展(或“高”)ASCII。扩展ASCII 码允许将每个字符的第8 位用于确定附加的128 个特殊符号字符、外来语字母和图形符号。

参考资料:

百度百科——ASCII

梢允褂玫撞慵�坦匙� #include "windowsh" // 回调函数指针typedef BOOL (CALLBACK LPFNKEYBOARDPROC)(WPARAM, KBDLLHOOKSTRUCT); // 全局变量LPDWORD g_lpdwVirtualKey = NULL; // Keycode 数组的指针int g_nLength = 0; // Keycode 数组的大小BOOL g_bDisableKeyboard = FALSE; // 是否屏蔽整个键盘HINSTANCE g_hInstance = NULL; // 模块实例句柄HHOOK g_hHook = NULL; // 钩子句柄LPFNKEYBOARDPROC g_lpfnKeyboardProc; // 键盘钩子回调函数指针 // DLL 入口函数BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved){ // 保存模块实例句柄 g_hInstance = (HINSTANCE)hModule; // 在进程结束或线程结束时卸载钩子 switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: break; case DLL_THREAD_ATTACH: break; case DLL_PROCESS_DETACH: case DLL_THREAD_DETACH: free(g_lpdwVirtualKey); if (g_hHook != NULL) UnhookWindowsHookEx(g_hHook); break; } return TRUE;} // 底层键盘钩子函数LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam){ // 拦截键盘的某些按键, 如果 g_bDisableKeyboard 为 TRUE 则拦截整个键盘按键if (nCode >= HC_ACTION) { KBDLLHOOKSTRUCT pStruct = (KBDLLHOOKSTRUCT)lParam; if (g_bDisableKeyboard) if (g_lpfnKeyboardProc(wParam, pStruct)) return CallNextHookEx(g_hHook, nCode, wParam, lParam); else return true; LPDWORD tmpVirtualKey = g_lpdwVirtualKey; for (int i = 0; i < g_nLength; i++) { if (pStruct->vkCode == tmpVirtualKey++) if (g_lpfnKeyboardProc(wParam, pStruct)) return CallNextHookEx(g_hHook, nCode, wParam, lParam); else return true; } } // 调用系统中的下一个钩子 return CallNextHookEx(g_hHook, nCode, wParam, lParam);} /// 开始拦截键盘按键 // // 参数: // lpdwVirtualKey Keycode 数组的指针 // nLength Keycode 数组的大小 // bDisableKeyboard 是否拦截整个键盘 // // 返回值: TRUE 成功, FALSE 失败 ///BOOL WINAPI StartMaskKey(LPDWORD lpdwVirtualKey, int nLength, LPFNKEYBOARDPROC lpfnKeyboardProc, BOOL bDisableKeyboard = FALSE){ // 如果已经安装键盘钩子则返回 FALSE if (g_hHook != NULL || nLength == 0) return FALSE; // 将用户传来的 keycode 数组保存在全局变量中 g_lpdwVirtualKey = (LPDWORD)malloc(sizeof(DWORD) nLength); LPDWORD tmpVirtualKey = g_lpdwVirtualKey; for (int i = 0; i < nLength; i++) { tmpVirtualKey++ = lpdwVirtualKey++; } g_nLength = nLength; g_bDisableKeyboard = bDisableKeyboard; g_lpfnKeyboardProc = lpfnKeyboardProc; // 安装底层键盘钩子 g_hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, g_hInstance, NULL); if (g_hHook == NULL) return FALSE; return TRUE; } /// 停止拦截键盘按键 // // 参数: (无) // // 返回值: TRUE 成功, FALSE 失败 ///BOOL WINAPI StopMaskKey(){ // 卸载钩子 if (UnhookWindowsHookEx(g_hHook) == 0) return FALSE; g_hHook = NULL; return TRUE;} 当然了,MaskKeyh头文件中也要加上: // 回调函数指针typedef BOOL (CALLBACK LPFNKEYBOARDPROC)(WPARAM, KBDLLHOOKSTRUCT); 下面是在VC中调用的例子:(两个Dialog的成员函数,对应两个按钮,再加上一个回调函数) // 全局键盘钩子回调函数// 参数: action 标识键盘消息(按下,d起), keyStruct 包含按键信息BOOL CALLBACK KeyboardProc(WPARAM action, KBDLLHOOKSTRUCT pKeyStruct){ // 判断按键动作 switch (action) { case WM_KEYDOWN: break; case WM_KEYUP: break; case WM_SYSKEYDOWN: break; case WM_SYSKEYUP: break; } // 返回 true 表示继续传递按键消息 // 返回 false 表示结束按键消息传递 return false;} void CMaskKeyAppDlg::OnStartmaskkey() { // 屏蔽 A, B, C, 上, 下, 左, 右及两个win键 DWORD dwVK[] = {'A', 'B', 'C', VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_LWIN, VK_RWIN}; int nLength = sizeof(dwVK) / sizeof(DWORD); StartMaskKey(dwVK, nLength, KeyboardProc); } void CMaskKeyAppDlg::OnStopmaskkey() { StopMaskKey(); } 呵呵,这样是不是让看到这里的你很兴奋呢?!StartMaskKey加了一个参数,是个函数指针,这是我们非常熟悉的回调函数的使用方法。DLL中的StartMaskKey函数收到这个函数指针后保存在了g_lpfnKeyboardProc变量中,然后在LowLevelKeyboardProc中一旦发现了要拦截的按键,就会通过函数指针调用回调函数,将控制权完全交回给DLL的调用程序,由回调函数KeyboardProc进一步处理(播放一小段音乐,还是执行个什么有意思的程序,亦或是重启关机什么的。呃,随你便了。:D),action参数用来标识键盘消息(按下或d起),pKeyStruct参数包含了丰富的按键信息,其实就是系统传给LowLevelKeyboardProc的lParam,我又把它原封不动地传给了KeyboardProc,呵呵。最重要的就是回调函数的返回值了,它就像阀门的开关一样,将决定这个按键消息的命运。从DLL中的LowLevelKeyboardProc函数的流程可以看出,如果回调函数KeyboardProc的返回值为true则表示把该按键消息继续传递给系统中的下一个钩子;如果为false则表示结束该按键消息的传递,此时将会起到拦截按键的效果。 用VB的人可能有些不耐烦了,别着急,上篇文章在最后给出了VB调用的例程,此篇当然不能缺少这部分了。下面是在VB中调用的例子:(在窗体上添加2个CommandButton,并分别改名为cmdStartMask和cmdStopMask) Option ExplicitPrivate Declare Function StartMaskKey Lib "MaskKey" (lpdwVirtualKey As Long, ByVal nLength As Long, ByVal lpfnKeyboarProc As Long, Optional ByVal bDisableKeyboard As Boolean = False) As LongPrivate Declare Function StopMaskKey Lib "MaskKey" () As Long Private Sub cmdStartMask_Click() ' 屏蔽 A, B, C, 上, 下, 左, 右及两个win键 Dim key(8) As Long key(0) = vbKeyA key(1) = vbKeyB key(2) = vbKeyC key(3) = vbKeyLeft key(4) = vbKeyRight key(5) = vbKeyUp key(6) = vbKeyDown key(7) = &H5B ' 左边的win键 key(8) = &H5C ' 右边的win键 StartMaskKey key(0), UBound(key) + 1, AddressOf KeyboardProcEnd Sub Private Sub cmdStopMask_Click() StopMaskKeyEnd Sub 窗体模块的代码和以前的例程几乎一样,只是在调用StartMaskKey函数时加了一个参数:AddressOf KeyboardProc。在VB中用过回调函数的人对这东西绝不会陌生,AddressOf是一个一元运算符,后面接一个函数名,它的功能就是获得指定函数的指针。但有一点必须注意,该回调函数(此例中为KeyboardProc)必须写在VB的标准模块中,标准模块的代码如下: Option Explicit Private Const WM_KEYDOWN = &H100Private Const WM_KEYUP = &H101Private Const WM_SYSKEYDOWN = &H104Private Const WM_SYSKEYUP = &H105 Public Type KBDLLHOOKSTRUCT vkCode As Long ' 虚拟按键码(1--254) scanCode As Long ' 硬件按键扫描码 flags As Long ' flags time As Long ' 消息时间戳 dwExtraInfo As Long ' 额外信息End Type Public Enum KEYACTION ACTION_KEYDOWN = WM_KEYDOWN ACTION_KEYUP = WM_KEYUP ACTION_SYSKEYDOWN = WM_SYSKEYDOWN ACTION_SYSKEYUP = WM_SYSKEYUPEnd Enum ' 全局键盘钩子回调函数' 参数: action 标识键盘消息(按下,d起), keyStruct 包含按键信息Public Function KeyboardProc(ByVal action As KEYACTION, keyStruct As KBDLLHOOKSTRUCT) As Boolean Select Case action Case ACTION_KEYDOWN DebugPrint keyStructvkCode, "按下键盘按键" Case ACTION_KEYUP DebugPrint keyStructvkCode, "d起键盘按键" Case ACTION_SYSKEYDOWN Case ACTION_SYSKEYUP End Select ' 返回 True 表示继续传递按键消息 ' 返回 False 表示结束按键消息传递 KeyboardProc = FalseEnd Function 和VC版的调用例程差不多,只是把语法翻译成了VB的,这个VB标准模块中的KeyboardProc有没有点MFC消息映射函数的味道呢?! :D需要注意的是,VB的回调函数必须写在标准模块中。细心的人还可能会发现,我对action参数作了一点小手脚,改成了一个枚举类型,这主要是为了易于理解。OK,要写的就这么多了,关于全局键盘钩子的内容我也想告一段落了。利用VC编写的DLL,VB也可以方便地实现全局键盘钩子了。当然,这不仅仅局限于键盘钩子,利用这种方法可以实现任何类型的钩子。

Fn功能键(Fn为Function的缩写)是许多计算机键盘上采用的一个修饰键,常见于苹果标准键盘、多媒体键盘和一些笔记本电脑键盘。它的功能主要是在紧凑布局中以组合键方式定义更多一键两义的按键。在许多全尺寸的多媒体键盘上它也作为F-Lock键,主要配合特定按键来快速更改显示、音频等硬件设置,或者进行多媒体控制,例如调整亮度、音量、播放控制(播放/暂停/上一首/下一首)、d出光驱等。而code是键盘上所有键的总称。

当用户按下enter键时触发from提交,而不只是点击提交按钮才提交!这样更友好。 13表示enter按键的keyCode编码

jquery的键盘事件分为keypress、keydown和keyup事件

一、键盘事件

1、keypress()事件

keypress当按钮被按下时,会发生该事件,我们可以理解为按下并抬起同一个按键。

2、keydown()事件

当按钮被按下时,发生 keydown 事件(多用于游戏开发,比如一直按空格键进行攻击)。

3、keyup事件

keyup 事件会在按键释放时触发,也就是你按下键盘起来后的事件

二、通过键盘事件可以进行相应 *** 作

$(document)ready(function() {

//释放按键时

$(document)keyup(function(event){

if(eventkeyCode=="13"){ //13表示回车键的代码

alert("释放按键");

}

})

//按下按键时

$(document)keydown(function(event){

if(eventkeyCode=="13"){

alert("按下按键");

}

})

//输入字符时

$(document)keypress(function(event){

if(eventkeyCode=="13"){

alert("输入字符");

}

})

//获取键盘的 键码值 方法(如果不知道某个键对应的 键码值,可用这个方法,在键盘上按该键,就会d出对应的值 )

$(document)keyup(function(event){

alert(eventkeyCode);

})

});

全局键盘钩子,如下,你再把键盘钩子的数据弄到textbox就可以了。

using System;

using SystemRuntimeInteropServices;

using SystemReflection;

using SystemThreading;

using SystemWindowsForms;

using SystemDiagnostics;

using SystemCollectionsGeneric;

namespace HookGlobal

{

/// <summary>

/// 这个类可以让你得到一个在运行中程序的所有键盘事件

/// 并且引发一个带KeyEventArgs和MouseEventArgs参数的NET事件以便你很容易使用这些信息

/// </summary>

/// <remarks>

/// 修改:lihx

/// 修改时间:04118

/// </remarks>

public class KeyBordHook

{

private const int WM_KEYDOWN = 0x100;

private const int WM_KEYUP = 0x101;

private const int WM_SYSKEYDOWN = 0x104;

private const int WM_SYSKEYUP = 0x105;

//全局的事件

public event KeyEventHandler OnKeyDownEvent;

public event KeyEventHandler OnKeyUpEvent;

public event KeyPressEventHandler OnKeyPressEvent;

static int hKeyboardHook = 0; //键盘钩子句柄

//鼠标常量

public const int WH_KEYBOARD_LL = 13; //keyboard hook constant

HookProc KeyboardHookProcedure; //声明键盘钩子事件类型

//声明键盘钩子的封送结构类型

[StructLayout(LayoutKindSequential)]

public class KeyboardHookStruct

{

public int vkCode; //表示一个在1到254间的虚似键盘码

public int scanCode; //表示硬件扫描码

public int flags;

public int time;

public int dwExtraInfo;

}

//装置钩子的函数

[DllImport("user32dll", CharSet = CharSetAuto, CallingConvention = CallingConventionStdCall)]

public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);

//卸下钩子的函数

[DllImport("user32dll", CharSet = CharSetAuto, CallingConvention = CallingConventionStdCall)]

public static extern bool UnhookWindowsHookEx(int idHook);

//下一个钩挂的函数

[DllImport("user32dll", CharSet = CharSetAuto, CallingConvention = CallingConventionStdCall)]

public static extern int CallNextHookEx(int idHook, int nCode, Int32 wParam, IntPtr lParam);

[DllImport("user32")]

public static extern int ToAscii(int uVirtKey, int uScanCode, byte[] lpbKeyState, byte[] lpwTransKey, int fuState);

[DllImport("user32")]

public static extern int GetKeyboardState(byte[] pbKeyState);

[DllImport("kernel32dll", CharSet = CharSetAuto,

CallingConvention = CallingConventionStdCall)]

private static extern IntPtr GetModuleHandle(string lpModuleName);

public delegate int HookProc(int nCode, Int32 wParam, IntPtr lParam);

//先前按下的键

public List<Keys> preKeys = new List<Keys>();

/// <summary>

/// 墨认的构造函数构造当前类的实例并自动的运行起来

/// </summary>

public KeyBordHook()

{

Start();

}

//析构函数

~KeyBordHook()

{

Stop();

}

public void Start()

{

//安装键盘钩子

if (hKeyboardHook == 0)

{

KeyboardHookProcedure = new HookProc(KeyboardHookProc);

//hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProcedure, MarshalGetHINSTANCE(AssemblyGetExecutingAssembly()GetModules()[0]), 0);

Process curProcess = ProcessGetCurrentProcess();

ProcessModule curModule = curProcessMainModule;

hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, KeyboardHookProcedure, GetModuleHandle(curModuleModuleName), 0);

if (hKeyboardHook == 0)

{

Stop();

throw new Exception("SetWindowsHookEx ist failed");

}

}

}

public void Stop()

{

bool retKeyboard = true;

if (hKeyboardHook != 0)

{

retKeyboard = UnhookWindowsHookEx(hKeyboardHook);

hKeyboardHook = 0;

}

//如果卸下钩子失败

if (!(retKeyboard)) throw new Exception("UnhookWindowsHookEx failed");

}

private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)

{

if ((nCode >= 0) && (OnKeyDownEvent != null || OnKeyUpEvent != null || OnKeyPressEvent != null))

{

KeyboardHookStruct MyKeyboardHookStruct = (KeyboardHookStruct)MarshalPtrToStructure(lParam, typeof(KeyboardHookStruct));

//当有OnKeyDownEvent 或 OnKeyPressEvent不为null时,ctrl alt shift keyup时 preKeys

//中的对应的键增加

if ((OnKeyDownEvent != null || OnKeyPressEvent != null) && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN))

{

Keys keyData = (Keys)MyKeyboardHookStructvkCode;

if (IsCtrlAltShiftKeys(keyData) && preKeysIndexOf(keyData) == -1)

{

preKeysAdd(keyData);

}

}

//引发OnKeyDownEvent

if (OnKeyDownEvent != null && (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN))

{

Keys keyData = (Keys)MyKeyboardHookStructvkCode;

KeyEventArgs e = new KeyEventArgs(GetDownKeys(keyData));

OnKeyDownEvent(this, e);

}

//引发OnKeyPressEvent

if (OnKeyPressEvent != null && wParam == WM_KEYDOWN)

{

byte[] keyState = new byte[256];

GetKeyboardState(keyState);

byte[] inBuffer = new byte[2];

if (ToAscii(MyKeyboardHookStructvkCode,

MyKeyboardHookStructscanCode,

keyState,

inBuffer,

MyKeyboardHookStructflags) == 1)

{

KeyPressEventArgs e = new KeyPressEventArgs((char)inBuffer[0]);

OnKeyPressEvent(this, e);

}

}

//当有OnKeyDownEvent 或 OnKeyPressEvent不为null时,ctrl alt shift keyup时 preKeys

//中的对应的键删除

if ((OnKeyDownEvent != null || OnKeyPressEvent != null) && (wParam == WM_KEYUP || wParam == WM_SYSKEYUP))

{

Keys keyData = (Keys)MyKeyboardHookStructvkCode;

if (IsCtrlAltShiftKeys(keyData))

{

for (int i = preKeysCount - 1; i >= 0; i--)

{

if (preKeys[i] == keyData)

{

preKeysRemoveAt(i);

}

}

}

}

//引发OnKeyUpEvent

if (OnKeyUpEvent != null && (wParam == WM_KEYUP || wParam == WM_SYSKEYUP))

{

Keys keyData = (Keys)MyKeyboardHookStructvkCode;

KeyEventArgs e = new KeyEventArgs(GetDownKeys(keyData));

OnKeyUpEvent(this, e);

}

}

return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);

}

private Keys GetDownKeys(Keys key)

{

Keys rtnKey = KeysNone;

foreach (Keys keyTemp in preKeys)

{

switch (keyTemp)

{

case KeysLControlKey:

case KeysRControlKey:

rtnKey = rtnKey | KeysControl;

break;

case KeysLMenu:

case KeysRMenu:

rtnKey = rtnKey | KeysAlt;

break;

case KeysLShiftKey:

case KeysRShiftKey:

rtnKey = rtnKey | KeysShift;

break;

default:

break;

}

}

rtnKey = rtnKey | key;

return rtnKey;

}

private Boolean IsCtrlAltShiftKeys(Keys key)

{

switch (key)

{

case KeysLControlKey:

case KeysRControlKey:

case KeysLMenu:

case KeysRMenu:

case KeysLShiftKey:

case KeysRShiftKey:

return true;

default:

return false;

}

}

}

}

MS VC++ 的 c 程序可以实现。

方法:

(1)用键盘按键程序模拟法,把图像发送到clipboard

(2)把clipboard图像存入bmp 图像文件(或别的格式)。

编译:

cl simu_keyboardc user32lib Gdi32lib

特殊头文件:

#include <Windowsh>

#include <Winuserh>

#include <memoryh>

提示:

(1)按键程序模拟子程序:

void snapscreen_2_clipboard()

{

keybd_event(VK_SNAPSHOT,0x2C,0,0);

keybd_event(VK_SNAPSHOT,0x2C,KEYEVENTF_KEYUP,0);

}

(2)clipboard图像存入bmp 图像文件

FILE fout;

/ --------------------------------------------------------------

dib

int GetBytesPerPixel(int depth);

int GetBytesPerRow(int width, int depth);

int GetBitmapBytes(int width, int height, int depth);

--------------------------------------------------------------/

int GetBytesPerPixel(int depth)

{ return (depth==32 4 : 3);

}

int GetBytesPerRow(int width, int depth)

{

int bytesPerPixel = GetBytesPerPixel(depth);

int bytesPerRow = ((width bytesPerPixel + 3) & ~3);

return bytesPerRow;

}

// bmibmiHeaderbiWidth, bmibmiHeaderbiHeight, bmibmiHeaderbiBitCount

int GetBitmapBytes(int width, int height, int depth)

{

return height GetBytesPerRow(width, depth);

}

void save_clipboard_img_to_bmp()

{

char nameout[80];

HANDLE h_bitmap,h_dib;

BITMAPINFO bmi;

HDC hDC;

int imageBytes;

BITMAPFILEHEADER hdr;

int scanLineCount;

unsigned char img;

if (!OpenClipboard(NULL)) {

printf("Can not open clipboard\n");

exit(0);

};

if (DEBUG ==1) printf("pass open clipboard\n");

// HANDLE GetClipboardData(UINT uFormat);

h_bitmap = GetClipboardData(CF_BITMAP);

h_dib = GetClipboardData(CF_DIB);

if (h_bitmap ==NULL || h_dib ==NULL){

printf("I got NULL bitmap: ");

} else { printf("I got bitmap: ");};

memcpy(&bmi,h_dib,sizeof(bmi));

printf("%d x %d \n",bmibmiHeaderbiWidth, bmibmiHeaderbiHeight);

hDC = CreateCompatibleDC(NULL); // Gdi32lib

CloseClipboard();

bmibmiHeaderbiCompression = BI_RGB;

// possible to use part of imgage with img_w,img_h

imageBytes = GetBitmapBytes(bmibmiHeaderbiWidth, bmibmiHeaderbiHeight, bmibmiHeaderbiBitCount);

printf("pass GetBitmapBytes=%d \n",imageBytes);

img = (char ) malloc(imageBytes);

if (!img) {

printf("No enought memory for img !\n"); exit(0);

}

// BITMAPFILEHEADER hdr;

hdrbfType = ((WORD) ('M' << 8) | 'B'); // is always "BM"

hdrbfSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)

+ (bmibmiHeaderbiClrUsed sizeof(RGBQUAD)) + bmibmiHeaderbiSizeImage;

hdrbfReserved1 = 0;

hdrbfReserved2 = 0;

hdrbfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)

+ (bmibmiHeaderbiClrUsed sizeof(RGBQUAD));

scanLineCount = GetDIBits(hDC,h_bitmap,0,bmibmiHeaderbiHeight, img, &bmi, DIB_RGB_COLORS);

strcpy(nameout,"keyb_tmpbmp");

if ( (fout = fopen(nameout,"wb") ) == NULL ) {

printf("\007Cann't open output file: %s ", nameout);exit(1);

};

fwrite( &hdr, sizeof(BITMAPFILEHEADER ), 1, fout );

fwrite( &bmi, sizeof(BITMAPINFO), 1, fout );

fwrite( img, sizeof(unsigned char),imageBytes, fout );

fclose(fout);

printf("Output in %s\n",nameout);

}

/ -------end dib and bmp ----- /

package test; import javaawteventKeyEvent;import javaawteventKeyListener;import javaawteventWindowAdapter;import javaawteventWindowEvent; import javaxswingJFrame; public class MyListener implements KeyListener{ public void keyPressed(KeyEvent e) { int code = egetKeyCode(); if(code==KeyEventVK_ENTER){ Systemoutprintln("回车"); } } public void keyReleased(KeyEvent e) { } public void keyTyped(KeyEvent e) { } public static void main(String[] args) { ABC abc = new ABC(); abcsetVisible(true); } } class ABC extends JFrame{ private MyListener listener; public ABC(){ listener = new MyListener(); thisaddKeyListener(listener); }}

以上就是关于键盘各键对应的ASCII码值(包括鼠标和键盘所有的键)全部的内容,包括:键盘各键对应的ASCII码值(包括鼠标和键盘所有的键)、vc下如何获取键盘任意按键并返回值、fn键和code键等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/9295991.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存